Get json from different elements

Hi there,
I was wondering how I can get the JSON from different elements, let me show it:

{
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        -40,
        780
      ]
    },
    {
      "parameters": {
        "functionCode": "return [{\n  json: {\n    postal_codes: ['LA96RA','ERROR','PH263AE']\n  }\n}];"
      },
      "name": "Set Postal Codes",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        230,
        780
      ]
    },
    {
      "parameters": {
        "fieldToSplitOut": "postal_codes",
        "options": {}
      },
      "name": "Split Out Postal Codes",
      "type": "n8n-nodes-base.itemLists",
      "typeVersion": 1,
      "position": [
        430,
        780
      ]
    },
    {
      "parameters": {
        "functionCode": "return ([\n{json: {\n    \"http1_status_3_position\": $items(\"http1\", 3, status),\n    \"http1_status_3_postcode\": $items(\"http1\", 3, postcode),\n    \"htp2_error_message\": $items(\"http22\", 2, error)\n}}\n]) \n"
      },
      "name": "Function",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        960,
        820
      ]
    },
    {
      "parameters": {
        "url": "=https://api.postcodes.io/postcodes/{{$json[\"postal_codes\"]}}",
        "options": {
          "ignoreResponseCode": true
        }
      },
      "name": "http1",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        660,
        710
      ]
    },
    {
      "parameters": {
        "url": "=https://api.postcodes.io/postcodes/{{$json[\"postal_codes\"]}}",
        "options": {
          "ignoreResponseCode": true
        }
      },
      "name": "http2",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        650,
        910
      ]
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "Set Postal Codes",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Postal Codes": {
      "main": [
        [
          {
            "node": "Split Out Postal Codes",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out Postal Codes": {
      "main": [
        [
          {
            "node": "http1",
            "type": "main",
            "index": 0
          },
          {
            "node": "http2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "http1": {
      "main": [
        [
          {
            "node": "Function",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "http2": {
      "main": [
        [
          {
            "node": "Function",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

I got the Status and Erro message, but I could not get the postcode

return ([
{json: {
    "http1_status_3_position": $item(2).$node["http1"].data["status"],
    "http1_status_3_postcode": $item(2).$node["http1"].data["status"],
    "htp2_error_message": $item(1).$node["http2"].data["error"]
}}
])

I got a solution:

    "http1_status_3_position": $item(2).$node["http1"].data["status"],
    "http1_status_3_postcode": $item(2).$node["http1"].json['result']["country"],
    "htp2_error_message":      $item(1).$node["http2"].data["error"]

If you want to recover postcode, you need to add your need this way:

$item(2).$node[“http1”].data[“result”][“postcode”]

What are the ways to access the node?

for example

  • return $items(‘NODE_NAME’);
  • return $items(“NODE_NAME”, 0, 0)[0].json