Trouble Accessing and Iterating Over Data from a Previous Node

Describe the problem/error/question

I am trying to access elements from a previous node (“Consulta”) and iterate over them using $node["Consulta"].json. However, this is returning an object that I’m unable to work with effectively, as it’s not in an iterable array form.

What is the error message (if any)?

No specific error message, but the output format is not as expected.

Please share your workflow

(Unfortunately, I cannot share the exact workflow due to privacy concerns, but the main issue is with accessing and iterating over the output of the “Consulta” node.)

Share the output returned by the last node

[Object: {"row_number": 2, "Confirmation": "2023-12-19", "Reservation Date": "2023-12-18 11:29:40", "Payment Method": "Card", "Club": "SPORTS CLUB ALPHA", "Participants": 6, "Contact": "John Doe", "Phone": 123456789, "Email": "[email protected]", "Event": "SPORTS CHAMPIONSHIP", "Amount": 48, "Tax ID": "AB123456C", "headers": "", "params": "", "query": "", "body": ""}]

Expected output:

[
  {
    "row_number": 2,
    "Confirmation": "2023-12-19",
    "Reservation Date": "2023-12-18 11:29:40",
    "Payment Method": "Card",
    "Club": "SPORTS CLUB ALPHA",
    "Participants": 6,
    "Contact": "John Doe",
    "Phone": 123456789,
    "Email": "[email protected]",
    "Event": "SPORTS CHAMPIONSHIP",
    "Amount": 48,
    "Tax ID": "AB123456C",
    "headers": "",
    "params": "",
    "query": "",
    "body": ""
  },
  // ... Additional objects ...
]

Information on your n8n setup

  • n8n version: Docker last version
  • Database (default: SQLite): SQLite
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: DSM Synology NAS

Are you using a code node?
If so, set the ‘run once’ option and use $("Consulta").all() to get all items.

3 Likes

Many many thanks!!

1 Like

Sorry just another question. What is the set to run once option?

I mean the “Run Once for All Items” setting.

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