Reputation: 163
I have a node-red flow where I need to do 2 rest calls and then do some data operations based on the results of those two calls.
The only way how I could solve it was to do both calls one after the other
Is there a way in node-red to branch a flow and then join again like
The function node above would be invoked twice. What I need is a node which would have multiple inputs and then wait for each msg.payload to arrive before it starts with the processing.
Thanks
Upvotes: 2
Views: 7640
Reputation: 62
Don't know if this is still an issue for you but take a look at this node. it waits for the configured msg.paths["pathname"] and merges them together in msg.paths
https://flows.nodered.org/node/node-red-contrib-wait-paths
Upvotes: 0
Reputation: 619
It is possible, using the split and join nodes.
Take a look at this example:
[{"id":"8eb8c9c4.605e88","type":"http in","z":"abe521f2.f083a","name":"","url":"/parallel","method":"get","upload":false,"swaggerDoc":"","x":124.5,"y":632,"wires":[["dff9f95f.6f84f8"]]},{"id":"dff9f95f.6f84f8","type":"change","z":"abe521f2.f083a","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"httpbin\":\"http://httpbin.org/get\",\"anything\":\"http://httpbin.org/anything/get\"}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":356.5,"y":631,"wires":[["4b5a9dfb.439594"]]},{"id":"4b5a9dfb.439594","type":"split","z":"abe521f2.f083a","name":"","splt":"\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"topic","x":526.5,"y":631,"wires":[["8238bd1f.80e7f"]]},{"id":"8238bd1f.80e7f","type":"switch","z":"abe521f2.f083a","name":"","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"httpbin","vt":"str"},{"t":"eq","v":"anything","vt":"str"}],"checkall":"true","outputs":2,"x":655.5,"y":631,"wires":[["ada1d5f5.b43148"],["7400821e.6dd82c"]]},{"id":"ada1d5f5.b43148","type":"http request","z":"abe521f2.f083a","name":"REST Service 1","method":"GET","ret":"obj","url":"{{{payload}}}","tls":"","x":833.5,"y":590,"wires":[["99c15809.ccd4c8"]]},{"id":"7400821e.6dd82c","type":"http request","z":"abe521f2.f083a","name":"REST Service 2","method":"GET","ret":"obj","url":"http://httpbin.org/anything/get","tls":"","x":834,"y":672,"wires":[["99c15809.ccd4c8"]]},{"id":"99c15809.ccd4c8","type":"join","z":"abe521f2.f083a","name":"","mode":"auto","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":"\n","joinerType":"str","accumulate":"false","timeout":"","count":"","x":1015.5,"y":626,"wires":[["6a617e7c.5a6de"]]},{"id":"6a617e7c.5a6de","type":"http response","z":"abe521f2.f083a","name":"","statusCode":"","headers":{},"x":1162,"y":626,"wires":[]}]
Upvotes: 1