Loop items and added the result of each iteration to the same array

Hello I have an array like this

ID_array: [{id:1},{id:3},{id:7}]
I make a loop of this ID_array to call to an http request to get all of the information of the client that belongs to that id.

I want to store each response of the http request store to an array and have like this: [{id:1, name: John, phone: 111},{id:3, name: Jack, phone: 222},{id:7, name: Mark, phone: 999}]

How do u do this?

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

@Ivy_Saskia_Notion_IS , you do not need to do anything extra. n8n does it for your automatically. If the API returns the data as {id:3, name: Jack, phone: 222} depending on the id the final outcome will the list of corresponding responses, just what you need.

1 Like

I know it returns the full object, what I want is to set every object on the same array, because I need like this to next steps of the workflow

@Ivy_Saskia_Notion_IS , that is exactly what it does automatically for you - an array of objects which you would use in the next step.

Perhaps you could share your workflow where it behaves differently?

Here’s a generic example of the workflow. The HTTP Request node will return an array of JSONs if JSON is what your API returns.

That is the input for the next node you want to add after HTTP Request will have data in the format [{<JSON>}, {<JSON>}, {<JSON>}]

2 Likes

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