How to enrich a list of nested items with another node

I have really tried to make this by myself but after a few hours decided to ask for help here.

I am trying to download a Notion database with a field of a list of relations to another table and I need to iterate over these lists for each item and call Notion to get the tag of each relation_id and put it back to the original list of items.

If anyone can simply give a sense of what nodes I would need to make it work, I would really appreciate it!

Hi @victoriano, welcome to the community :wave:

Have you tried the Merge node? This can merge data coming from two inputs. So if you have one node returning multiple items and a second node returning data for each individual item, you can join the data together with a Merge node like so:

Example Workflow
{
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "functionCode": "return [{\n  json: { \n    my_id: 1\n  }\n}, {\n  json: { \n    my_id: 2\n  }\n}, {\n  json: { \n    my_id: 3\n  }\n}];"
      },
      "name": "Set Example List",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        450,
        300
      ]
    },
    {
      "parameters": {
        "url": "=https://reqres.in/api/users/{{$json[\"my_id\"]}}",
        "options": {}
      },
      "name": "HTTP Request for Each Iteam",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        650,
        400
      ]
    },
    {
      "parameters": {
        "mode": "mergeByIndex"
      },
      "name": "Merge",
      "type": "n8n-nodes-base.merge",
      "typeVersion": 1,
      "position": [
        850,
        300
      ]
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "Set Example List",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Example List": {
      "main": [
        [
          {
            "node": "HTTP Request for Each Iteam",
            "type": "main",
            "index": 0
          },
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request for Each Iteam": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    }
  }
}

You can copy and paste the JSON above right into your n8n canvas. This specific example doesn’t use Notion because I don’t have a suitable structure ready in my notion account. The principle should, however, work regardless of which nodes exactly you have in use :slight_smile:

Hope this gives you a pointer! Give me a shout if something isn’t quite working when trying this on your end.