Accessing nested objects and arrays using the new code node

Describe the issue/error/question

Hi I just upgraded by instance to the latest version to make use of the new Code node, but realized it works a bit differently than it used to. Im trying to return a nested array from a previous HTTP request. The output is showing only 1 item, but there is an array of numerous item with that object that I need to pull out. Is there a way to use dot notation like with the old Function node?

Information on your n8n setup

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

Hey @pford,

Can you share the input json and what you are expecting the output json to look like? In theory the code node should work the same but some of the internal variables have been changed so if you were to use .all() it would be the same as using .items in the old function node so you would still need to loop over the data although if there is only item you could just do $("node name").first().json.nfts

Gotcha. Basically the input on the left is the result of an HTTP node, but the API returns the array “nfts” inside of a JSON object, so it says there’s only one item. I’d like to pull out that “nfts” array so that there are, say, 30+ items that I can then perform code on for each item in the array.

Hey @pford,

Pefect, Give $("node name").first().json.nfts a bash and see if it works.

Wonderful, yes that worked perfectly!

1 Like

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