Describe the problem/error/question
Hi there,
anyone an Idea why I can not access the second key/value pair in a prompt?
The first one is working fine (value_1). I do not have access to the second one (value_2).
Please find the screenshot attached:
(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)
Share the output returned by the last node
Information on your n8n setup
n8n version:
Database (default: SQLite):
n8n EXECUTIONS_PROCESS setting (default: own, main):
Running n8n via (Docker, npm, n8n cloud, desktop app):
Operating system:
1 Like
rbreen
April 8, 2025, 12:22pm
2
HI @fablan1 ,
Can you upload your n8n workflow? It can depend on what other steps you have in your flow.
Best,
Robert
rbreen
April 8, 2025, 12:26pm
3
Here’s a workflow that I created. I got both values to show up. hope this workflow helps.
Found the solution. I used the loop from n8n by mistake.
Without looping:
const items = $input.all();
const result = {
json: {
value_1: items[0].json.text,
value_2: items[1].json.Output
}
};
return [result];
What I have done before:
let data = []
// Loop over input items and add a new field called 'myNewField' to the JSON of each one
for (const item of $input.all()) {
data.push({"value_1":item.json.text, "value_2":item.json.Output})
}
return data
Which created this:
[
{ "value_1": "ABC", "value_2": undefined } },
{ "value_1": undefined, "value_2": "XYZ" } }
]
That’s why it is not working. Trying to access $json.value_2
in the first item is undefined.
That’s the right way:
const items = $input.all();
const result = {
json: {
value_1: items[0].json.text,
value_2: items[1].json.Output
}
};
return [result];
2 Likes
system
Closed
April 20, 2025, 8:41pm
6
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.