I am trying to build a function node that takes this input from a switch node:
topic: "Name of Alarm" payload: 1
I am trying to create an array within a function node that pushes the topic inputs, into an array. This is the code I have in my function node so far:
context.outputAlarms = [];
context.outputAlarms.push(msg.topic);
msg.payload = context.outputAlarms;
return msg;
And this is the debug node output: C-1A SEL FOR RECV SYS AUTO STP : msg : Object { "payload": [ "C-1A SEL FOR RECV SYS AUTO STP" ], "topic": "C-1A SEL FOR RECV SYS AUTO STP", "_msgid": "bbe3efc0.3816a" }
I'm using "context" because from what I understand it is a module that stores data in that certain node. I believe my issue is that the array isn't adding new items, it is overwriting them. Can anyone point me in the right direction?