> For the complete documentation index, see [llms.txt](https://doc.duaer.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.duaer.com/troubleshooting/code-node-doesnt-return-items-properly.md).

# Fix "Code doesn't return items properly" in the Duaer Code node

The Duaer Code node expects an array of items or an object. A missing return, a string, or an array of numbers raises these errors.
## Duaer Code node errors

- Code doesn't return items properly: Run Once for All Items mode with no return, or an array holding strings or numbers.
- Code doesn't return an object: Run Once for Each Item mode without an object.
- Code doesn't return a single object: Run Once for Each Item mode returned an array. To turn one item into many, switch to Run Once for All Items.
- A 'json' property isn't an object: you returned something like { json: "text" }. json must hold an object.
- Unknown top-level item key: some items in the array use json and some do not.

## Return this shape

Run Once for All Items mode:

```
return $input.all().map((item) => ({
  json: { ...item.json, total: item.json.price * item.json.qty },
}));
```

Wrap plain strings first: return list.map((name) => ({ json: { name } })). Refer to [Split an array into items in Duaer](/snippets/split-array-into-items.md).
## Questions

### Can the Duaer Code node return a single object?

Yes. Duaer treats one object as one output item. For several, return an array of objects.

### Which Duaer Code node mode should I use?

In Duaer, use Run Once for All Items to total, split, or change the item count. Run Once for Each Item to edit each item and keep the count.

## Related

- [Write a short step with Code in Duaer](https://doc.duaer.com/build/code.md)
- [Split an array into separate items in Duaer](https://doc.duaer.com/snippets/split-array-into-items.md)
- [Understand Duaer’s data structure](https://doc.duaer.com/data/data-structure.md)
- [Use built-in methods and variables in Duaer](https://doc.duaer.com/code/builtin.md)

