I am trying to set an array into flow context but unable to write the appropriate code.
please help. I get only null. i dont know whcih part of the code in function node is incorrect.
const data = Array.isArray(msg.payload) ? msg.payload : []
const out = []
data.forEach(i => {if (i.payload) out.push(i.payload)
else out.push(null)})
flow.set('abc', out)
return msg;
[{"id":"ddec360045e28541","type":"inject","z":"cd84b99c9e598453","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":390,"y":4320,"wires":[["3b7ac0241e41b171"]]},{"id":"3b7ac0241e41b171","type":"change","z":"cd84b99c9e598453","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"[\"▼ 15.2 Day\",\"▼ 44.2 Day\",\"▼ 17 Day\",\"▲ 24 Min\",\"▲ 50 Min\",\"▼ 4.8 Day\",\"▼ 4.8 Day\",\"▼ 55 Min\",\"▼ 1 Min\",\"▼ 3.5 Day\",\"▼ 226 Min\",\"▼ 20 Min\",\"▲ 242.8 Day\",\"▲ 242.8 Day\",\"▲ 288.8 Day\",\"▼ 9.9 Day\",\"▼ 72 Min\",\"▲ 242.9 Day\",\"▲ 18 Min\",\"▼ 60 Min\",\"▼ 5.4 Day\",\"▼ 53 Min\",\"▼ 52 Min\",\"▼ 552 Min\"]","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":4320,"wires":[["ad927c125cf61172","137c9bbf5fa3b9e0"]]},{"id":"ad927c125cf61172","type":"function","z":"cd84b99c9e598453","name":"flow context","func":"const data = Array.isArray(msg.payload) ? msg.payload : []\nconst out = []\ndata.forEach(i => {if (i.payload) out.push(i.payload)\n else out.push(null)})\nflow.set('abc', out) \nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":790,"y":4320,"wires":[["777259245f6db068"]]},{"id":"777259245f6db068","type":"debug","z":"cd84b99c9e598453","name":"debug 16","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":980,"y":4320,"wires":[]},{"id":"137c9bbf5fa3b9e0","type":"debug","z":"cd84b99c9e598453","name":"debug 17","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":760,"y":4380,"wires":[]}]