Hi, I’m stuck on a node again. In the edit fields node, I put this JSON code to give it 2 items as input to test how the “loop” node worked. However, it’s giving me an error and I don’t know why.
[
{
“name”: “First item”,
“code”: 1
},
{
“name”: “Second item”,
“code”: 2
}
]
What is the error message (if any)?
Please share your workflow
(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.)
The Edit Fields node in JSON mode expects a single object, not an array, which is why that errors. It also outputs one item per input item, so it can’t turn one incoming item into two no matter what you paste in.
For test data with multiple items, use a Code node instead:
That gives the Loop node two real items to iterate over.
If you’d rather not use code, keep the array as a single field in Edit Fields and add a Split Out node after it pointing at that field. Same result, two items.
Look at the purple bar above the OUTPUT panel in your screenshot: “This data is pinned”. I think so that Nick isn’t putting that JSON into the node at all, the mode is Manual Mapping and Fields to Set is empty, so the node isn’t producing anything.
He clicked the pencil icon on the OUTPUT panel and pasted the array there as pinned test data. You can do the same: open the node, click the pencil, paste, save.
Only works for manual runs from the editor though, pinned data is ignored in production.
Not quite. Pinning doesn’t execute anything. The node still does nothing, n8n just hands that data to the next node so you can test without a real data source.
That’s fine for playing with the Loop node in the editor, which is all the video is doing. But once you activate the workflow the pin is ignored and Edit Fields outputs nothing.
So: to test, pin it. To actually generate those two items in a real workflow, use the Code node from my first reply.
I checked the video. He opens the Set node and edits the output directly from the icon in the top right, then saves. n8n pins it from there. Same point though, the data is pinned rather than produced by the node.
Replace the “Edit Fields” node with a “Code” node, as Edit Fields only modifies existing items rather than generating multiple new items from a raw array.
Paste this into the Code node to correctly pass two items to your loop: return [{ json: { name: "First item", code: 1 } }, { json: { name: "Second item", code: 2 } }];