Split up the json array, while adding additional data from a different response

Hello community,

I am sending HTTP request which returns an array in a json format. I am spliting up that array to be able to create individual Airtable records based on that data via this function:

const newItems = [];
for (const item of items[0].json.value) {
newItems.push({json: item});
}
return newItems;

Than I am using Set to add the values from that operation prior to appending them to Airtable base. The issue is that I am also trying to add THE SAME value obtained from a different HTTP request and populate it to every item from the previous step:

On this screenshot I am getting 95 results from the “split up” function, and I’m able to set them via expression: {{$node[“Split up”].json[“Property”][“AptHomePage”]}}.

However, I can’t find a way to also add the result from a different node {{$node[“HTTP Request2”].json[“value”][0][“ManagementCompanyName”]}} to be able to copy that for EVERY value from the previous step.

As you can see on the screenshot, it is possible to set it only to the first value of the array.

Are there any options to attach this value to every element of that divided array? This value is obtained from a different HTTP request and is always the same for every item from the array.

Basically, I have 2 requests: one of them gets the name of the Management company (the same for every website) and the other gets the list of all the websites assosiated with this Management Company.

Sounds to me that this can be done with the merge node. Check the example below:

{
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "url": "https://mockup-pj5l0yxsjrbr.runkit.sh/",
        "options": {}
      },
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        590,
        300
      ],
      "notesInFlow": true,
      "notes": "Mockup data"
    },
    {
      "parameters": {
        "functionCode": "const ids = items[0].json\n\n\nreturn ids.map(id => ({ json: { id } }))\n\n"
      },
      "name": "Function",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        830,
        300
      ],
      "notesInFlow": true,
      "notes": "Map array"
    },
    {
      "parameters": {
        "mode": "multiplex"
      },
      "name": "Merge",
      "type": "n8n-nodes-base.merge",
      "typeVersion": 1,
      "position": [
        1100,
        570
      ]
    },
    {
      "parameters": {
        "values": {
          "boolean": [
            {
              "name": "test",
              "value": true
            }
          ]
        },
        "options": {}
      },
      "name": "Set",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        590,
        590
      ]
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          },
          {
            "node": "Set",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "Function",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Function": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    }
  }
}

Thank you! I googled all around, but was stupid enough not to look at the multiplex property!

Thanks a ton! Perfect as always!

Glad that it worked. To be honest, I also had completely forgotten the multiplex option :sweat_smile:.