Various HTTP request

Hi. I have an array with some URLs to make several HTTP request (about 40). I use a "split" node to split each message and make the HTTP request (using the node), and then I use a "join" node to join each of the requests into a single array (each request returns me a JSON with around 1000 values or more). The thing is that doing several tests, I realized that at the output of the HTTP request node, the responses were not in the same order as the input URLs. I assume that the reason is because the time it takes to make the request is different for each URL and they are coming out in the order in which they manage to make the request, and not in the order of arrival to the node. I need the output array to be in the same order as the input array because later I need to make the relationship between the URLs and the resulting JSON.

because later I need to make the relationship between the URLs and the resulting JSON.

The output of the http request node also contains the original url, so you have the information you need.

1 Like

Add a topic to each array entry & use key value mode in the join node. Then each response will always be available at msg.payload.topic (wheretopic is the topic you sent.). You can also include as much extra info as you wish in the msg & pick it up at the other side of the http request node.

1 Like

If you used the split node there should be a msg.parts property - which has a msg.parts.index which is indeed the index into the original array. If the parts are preserved then auto-join should put them back in order.

1 Like

Thank you, I hadn't notice that the URL is in the message. I was only checking the payload, this was the solution

1 Like

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