Im sure Im missing something simple here.
Im pushing some items onto an array then saving to the flow context.
I do this in a few different function blocks.
Another function block will get all of these arrays from the flow context for further processing. This is where Im stuck.
I can get the array, and send it straight into a debug and it is an object, containing an array of x items. This all looks good.
The job is to simply grab the context, and push everything onto a single array.
Here is that last function, and the output I was getting was empty, I know this code doesnt make sense but thats because I tried a whole bunch of things before giving up for the day.
let newObj = [];
let av = flow.get('av');
let io = flow.get('io');
// av.forEach(function(element) {
// newObj.push(element);
// });
// io.forEach(function(element) {
// newObj.push(element);
// });
for (let index = 0; index < av.length; index++) {
// newObj.push av[index];
node.send(av);
}
// msg.payload = av;
return msg;
Specifically, why couldnt I push the value onto the new object here?
for (let index = 0; index < av.length; index++) {
// newObj.push av[index];
node.send(av);
}
and Im sure theres a better way to do what Im doing here which Id be happy to go down that road once I get the basics sorted. Ill probably rewrite all of this once I know whats happening as need the data ordered correctly so I think I should use objects or do better error checking with the array as the order is going to be important. But thats a seperate thing for now. Thanks!!