Hi
I’m newish so be gentle.
I am struggling with a function that creates an array with msg.payload, having been initiated by injecting a random value (doesn’t matter what).
(Values or type that you set doesn’t matter)
The function just passes through the injected msg.
I can obviously modify msg.payload or insert objects but it just won’t create that array.
It has worked on other functions but being new, perhaps there is a subtle difference I am missing.
You inject a number (timestamp) from an inject node I presume.
So msg.payload is now a number, not an array. So you would need to set it as an array in your function code first
e.g. msg.payload = []; initialise an empty array
Then you can do msg.payload[0] = 1;
If you injected a json of value [ ] it would of worked also, as that would have set msg.payload to an empty array.