How can i initialize a variable in JS file with msg.payload or context.flow() variable?

hi i want to use flow variable or msg.payload variable which is array to initialize a variable in JS file

i used this.context().flow.get("name") but, it didn't work because the execution of that line is earlier than initializing of context().flow variable on node flow

and i also tried just input that value but that was "undefined" in JS file console.log() ... in my opinion the type of data was array but it just regard it as like string "msg.payload" literally. (maybe..?)

so please let me know how can i initialize the variable using msg.payload or context.flow()

Which? The approach for each is very different. For example, your .js file will not have any msg data except inside the msg handler function. this.on('input', inputMsgHandler). That function is called whenever an instance of your node receives a msg in a flow.

Can't help with the flow variable issue since you haven't explained any of the context of your node. However, obviously you have to have set a value to that context before you reference it in your node.

i just tried make a html page with "http in" node and i need to put some dynamic data into that html page
but all the ways i treid to put the data into that page failed..

it doesnt matter that flow or msg.payload but both of way i failed

here's my flow and .JS file
the output of console.log in .JS file was [object Object] it seems undefined

This appears to be a different question. If so, please create a separate thread so it can be better answered.

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