Hello
Is possible to generate a msg from a variable ?
Suppose I need a msg , like msg.Out.
But, "Out" comes from the variable.
var x = "Out";
var value = "abc";
(function or something else) => msg.Out = value;
Hello
Is possible to generate a msg from a variable ?
Suppose I need a msg , like msg.Out.
But, "Out" comes from the variable.
var x = "Out";
var value = "abc";
(function or something else) => msg.Out = value;
You're likely looking at payload
: https://nodered.org/docs/user-guide/messages
https://nodered.org/docs/user-guide/writing-functions
No.
I need to generate new (and multiple) msg with variable name.
Well, then still see the working with messages
documentation. The msg
is an object, which means you can talk to it like an object. if you were to hardcode things you can use msg.Out
to reference that property, but since it is an object you can instead use msg['Out']
to do the same. And instead of putting a string 'Out'
there you can put your variable there. Simply said,
var x = "Out";
var value = "abc";
msg[x] = value;
Thanks, afelix , is working