Just trying to learn Node-Red, and struggling with handling messages.
I have a node that queries a mysql database and returns a payload containing an array of objects.
payload:
I am wanting to pass the values to a dashboard graph node. However I believe I need to pass it an array in the form
payload: array[64]
[0...9]
[0: 22.2]
.
.
etc.
I've tried a function -
var outmsg = [];
for (var w in msg)
{
outmsg.push(w.Temperature);
}
return {payload: outmsg, topic: msg.length};
Obviously this is completely the wrong way of doing it... Can anyone help please?
ps. Sorry if this is a duplicate of something answered somewhere else. I did google, but found nothing.
It is best practice to not recreate messages, but to pass on the input message if possible, so the following is better:
for (var i in msg.payload) {
msg.payload[i] = msg.payload[i].time
}
return msg;