Group into one JSON item

Describe the issue/error/question

How to group a GET request into one items coming from multiple items

What is the error message (if any)?

Hi all, apologies if not using the right terms, but I have a GET request from a specific API that I get, and now I need to group the results
Currently they come out as [0].id, [1].id, so I cannot use the data dynamically.

In order to group them I use the following workflow now, but I believe there is a better way to do this dynamically instead of every time having to assign the fields

{
  "nodes": [
    {
      "parameters": {
        "functionCode": "return items[0].json[\"records\"].map(r => ({ json: { id: r.id, name: r.Name  }}));"
      },
      "name": "Takes fields JSON",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        720,
        300
      ],
      "notesInFlow": true,
      "notes": "Normalizes JSON"
    }
  ],
  "connections": {}
}```

Thank you very much in advance.

Hey @Jorge_M,

Do you have some sample json data you can share? My first thought is maybe the Item Lists node can help but without seeing the structure it is hard to say.

Hi @Jon ,
Missed this topic. I ended up solving it using a function with:

return items[0].json.records.map(item => {

  return {

    json: item

  }

});

Thank you :slight_smile: .