4

I need to do HTTP request on each url in array in Node.red. Basically I want to filter URLs by their API response. How do I do this? I cannot find any "loop" nodes or anything.

Kuroki Kaze
  • 8,161
  • 4
  • 36
  • 48

2 Answers2

3

There's a splitter node (node-red-contrib-splitter) which splits a payload-array into separate messages. When a message (msg) arrives, the configured variable will be iterated over.

See: https://www.npmjs.org/package/node-red-contrib-splitter

kmarabet
  • 1,087
  • 3
  • 14
  • 31
2

Okay, solved it. I've made node that expects array of URLs in msg.items and inserts them one by one in msg.payload (request metadata goes to msg.itemData), while collecting real msg.payload into msg.itemsResult. Switch after node decices to fire loop step or (if msg.payload == false), fire "result pin".

loop in Node-RED

After i got it working, I saw you can return two or more values from one node, by returning array of messages, so it should be possible to make loop in one node, w/o Loop Switch.

Kuroki Kaze
  • 8,161
  • 4
  • 36
  • 48