Looping over input of Input

Describe the issue/error/question

I get a response from an HTTP node like: [{ “data”:{ “DOMAIN”: [“hi.de”,“bye.de”] }}]
Now I want to iterate through the domains and send them separately to an HTTP node. I tried multiple ways and asked chatGPT, but I am just getting errors, that I am not returning the right property.

What is the error message (if any)?

Please share the workflow

{
  "meta": {
    "instanceId": "009244bccd8ee7c5688a00b5787b111f00894c3bb878b3dbfd65483af4c7ae50"
  },
  "nodes": [
    {
      "parameters": {
        "jsCode": "const newItems = [];\n\nfor (const item of items[0].json.value) {\n  newItems.push({json: item});\n}\n\nreturn newItems;"
      },
      "id": "4770427c-85f5-4958-83c1-2f3b702d2412",
      "name": "Code6",
      "type": "n8n-nodes-base.code",
      "typeVersion": 1,
      "position": [
        -900,
        640
      ]
    },
    {
      "parameters": {
        "url": "=https://www.virustotal.com/api/v3/ip_addresses/{{$node[\"Code6\"].json[\"id\"]}}",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "x-apikey",
              "value": "x"
            }
          ]
        },
        "options": {}
      },
      "id": "b40bf2fc-1f9c-4869-ac34-6e45016f8d08",
      "name": "HTTP Request4",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 3,
      "position": [
        -760,
        640
      ]
    },
    {
      "parameters": {
        "jsCode": "items[0].json = {\n    value: [\n        {id: \"45.117.143.205\"},\n        {id: \"103.145.13.121\"}\n    ]\n};\n\nreturn items;"
      },
      "id": "4ab31d35-4aa7-4e28-aad1-ad6452798984",
      "name": "Code7",
      "type": "n8n-nodes-base.code",
      "typeVersion": 1,
      "position": [
        -1100,
        640
      ]
    }
  ],
  "connections": {
    "Code6": {
      "main": [
        [
          {
            "node": "HTTP Request4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code7": {
      "main": [
        [
          {
            "node": "Code6",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

This is what I've tried and worked for me. But it doesn't match to the input I got. So how do I have to change my Javascript Code to match to the input structure?

Information on your n8n setup

  • n8n version: latest
  • Database you’re using (default: SQLite): -
  • Running n8n with the execution process [own(default), main]:
  • Running n8n via [Docker, npm, n8n.cloud, desktop app]:

Hi @DJ_Strickson

Welcome to the community!

Have you tried the Item lists node?
This will allow you to split out an array that exists in an item.
Should be fairly self explanatory how to use it, so please have a go with that node and let us know if you got it working.

1 Like

Hey,
so I used that split node, and it worked. Thanks

2 Likes

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