Search code examples
arraysnode.jsnode-red

How would i push a stream of messages into one array?


I have a stream of objects that come in one at a time to a debugger node. I want to be able to grab the objects and store them into one array once the objects stop streaming from an rss feed. The issue is I won't know how many of these objects will be coming through.

I've tried pushing the objects into an array that i store into a flow context, but I have to believe there's a much better and less messy way of doing this in node-red.


Solution

  • Look at the join node, it has a number of modes for collecting messages and assembling an array of payloads.

    Since you do not know how many, the time out node may be the best bet