How to declare and use the variable in Node-Red

Hi all , I am doing a simple test which consist of a button node to send the "msg.topic" to the function node when it is pressed via the dashboard UI. Code is shown in the first picture and the second picture shows the error warning when i try to deploy it. I am not sure if this format is correct to initialize the variable and get called when button is pressed.

I am planning to use this variable for the next function node. But first i have to make sure that this first function node is working.

image

image

a should be a string (in this case)

flow.set("a",1)

flow.get("a") = 1

got it! Thanks a lot!

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