How to send(publish) payload data sequentially?

Hi , I want to send Database's column data .
/////////////////////////////////////////////////////////////////
msg.reqList = ;//create empty array

var i = 0;
msg.payload.rows.forEach(function(e) {
let row = e.req_cmd;
msg.reqList.push(row);
i++;
})

msg.payload=msg.reqList;
msg.topic=msg.mac_addr;
for(var j=0;j<msg.payload.length;j++){
node.send(msg.payload[j]);
}
return msg;
///////////////////////////////////////////

After doing this code, I found debug node shows like that

["CM:142/MDNM/1","CM:846/MDNM/2","CM:691/MDNM/3"]

it's not result i want

When i subscribe 'msg.topic' ,topic have to show like that

CM:142/MDNM/1
CM:846/MDNM/2
CM:691/MDNM/3

How can I do like that??
I want to publish array's element in order. Help me plz !!

I suggest reading the node-red docs page Writing Functions where it will show you how you can easily use node.warn() to insert debug messages into your function, which get displayed in the debug pane. That way you can work out which bit of your function is not working correctly.

Note that anything you send should be an object with, in your case I think, payload and topic properties, so you need to make sure that what you push into your msg.reqList array is be an object with those properties.

[Edit] Also, for the future please see this post for how to post flows or code so that the forum does not mess with it - How to share code or flow json

Thanks!! I solved it

Share how? :slight_smile:

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.