Always returns one value for simple JS code transformation

I am trying to very simply output a modified column for a spreadsheet. My plan is more complicated but trying to make a simple example so we can debug it.

No matter what I do, i always only get one item output. I want the output to be an entire table with a modified column.

Why do i only get one item as the output?

const items = $input.all();
const updatedItems = items.map((item) => {
  item.json.Amount = 10;
  return item;
});
return updatedItems;

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Welcome to the community @emersenneprimes !

Tip for sharing information

Pasting your n8n workflow


Ensure to copy your n8n workflow and paste it in the code block, that is in between the pairs of triple backticks, which also could be achieved by clicking </> (preformatted text) in the editor and pasting in your workflow.

```
<your workflow>
```

That implies to any JSON output you would like to share with us.


Your test appears to be “faulty”. In any case, the issue is not with the code. It works as per your code logic - an extra property added to each incoming item. Therefore, the issue is likely rather with your Google Sheet node.

As per your screenshot, when you run the test, you actually exclude the spreadsheet data and thus only one item is returned because in this case the input data to Code node is just [{json:{}}]. If you run the following code you will get the same result:

const items = [{json:{}}];
const updatedItems = items.map((item) => 
  { item.json.Amount = 10; return item; }
);
return updatedItems;

If you want to debug the issue, do the following

  1. Read the data with Google Sheets node
  2. Pin the data, so you do not make more API calls and work on the same set of data

On the side note, to demonstrate the Code works fine (many items returned), try the following workflow.

How am I excluding the spreadsheet data? I don’t understand this part.

It says 50 items passed through from the Google Sheets node.

Side question: how do i copy a workflow in JSON?

Figured out how to get the JSON. Here it is

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