Backend and frontend communication

module.exports = function(RED) {
var myObject = {"x":1,"y":2};/myobject/
function LowerCaseNode(config) {
var node = this; t
his.on('input', function(msg) {
/??how to access "flow" object ?? flow.get("xxx")??/
msg.payload = msg.payload.toLowerCase();
node.send(msg); }); }
RED.nodes.registerType("lower-case",LowerCaseNode); }

</script type="text/javascript">
RED.nodes.registerType('lower-case',{ category: 'function', color: '#a6bbcf', defaults: { name: {value:""} },
icon: "file.png",
label: function() { return||"lower-case"; },
oneditprepare: function () {
alert(myObject['x']);/?? how to get "js" object ??/
} });


Hi @cmdares

please try to format your code using the </> button in the formatting toolbar. That will make it much easier to read. It took me a while to spot your questions hidden in the code.

The documentation for using Context in your node is here: Node context : Node-RED

There is no built-in way for the editor side to directly access runtime variables. If you really need to do this, you would have to create a new admin HTTP endpoint in your .js file that you can call in your .html file to access the information.

There is a high-level description of how to do that here: javascript - Send data on configuration - Stack Overflow

thanks! I'll try the way.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.