How to leave only child items of an object in the HTTP request?

My HTTP request returns more info then I need. So i need only the array of items in the datadata array.
How to tell this node to go into “data” property and use this as the result array?
The url: https://datausa.io/api/data?drilldowns=Nation&measures=Population

Hey @artildo!

For this, you will have to use the Function node. Below is the workflow that can use

{
  "nodes": [
    {
      "parameters": {
        "url": "https://datausa.io/api/data?drilldowns=Nation&measures=Population",
        "options": {}
      },
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        550,
        250
      ]
    },
    {
      "parameters": {
        "functionCode": "return items[0].json.data.map(item => {\n  return {\n    json: item\n  }\n});\n \n"
      },
      "name": "Function",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        750,
        250
      ]
    }
  ],
  "connections": {
    "HTTP Request": {
      "main": [
        [
          {
            "node": "Function",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

@harshil1712 Thank you very much

1 Like