Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple HTTP requests in Node-RED

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.

like image 385
Kuroki Kaze Avatar asked Oct 19 '25 08:10

Kuroki Kaze


2 Answers

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

like image 65
kmarabet Avatar answered Oct 20 '25 22:10

kmarabet


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.

like image 42
Kuroki Kaze Avatar answered Oct 20 '25 23:10

Kuroki Kaze



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!