Return Items the Way n8n Expects

Roadblock: your n8n Function node keeps throwing "items is not iterable" or outputs nothing. n8n wants an array of { json } objects — this template converts any plain array correctly.

The Snippet

// n8n Function node — the #1 gotcha: you must return [{ json }, ...]
const contacts = [
  { name: "Amy", email: "amy@co.com" },
  { name: "Bob", email: "bob@co.com" },
];
// Wrap every element so downstream nodes can read it:
return contacts.map((c) => ({ json: c }));

Implementation Steps

  1. Add a Function (or Code) node to your workflow
  2. Build your plain array however you like
  3. Wrap each element in { json } before returning

All templates