# Return function response as multiple items

**URL:** <https://community.n8n.io/t/return-function-response-as-multiple-items/20029>\
**Category:** Questions\
**Tags:** data-transformation\
**Created:** [November 22, 2022, 9:15am UTC](https://community.n8n.io/t/return-function-response-as-multiple-items/20029 "2022-11-22T09:15:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Samuel\_Simonney](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/samuel_simonney/32/12166_2.png) [@Samuel\_Simonney](https://community.n8n.io/u/Samuel_Simonney)\
**Post date:** [November 22, 2022, 9:15am UTC](https://community.n8n.io/t/return-function-response-as-multiple-items/20029/1 "2022-11-22T09:15:42Z")

</div>

Hi,  
I have a question about how to return multiple items after a function node.  
I have 2 arrays in input and I made a filter with an include so in return I have an array with the values I’m looking for.  
I just want to return this array as multiple items for the next node and I’ve seen as in this [thread](http://community.n8n.io/t/how-to-iterate-over-an-array/885) that some code like this with my one dimension array would work :

```auto
const newItems = [];

for (const item of myArray) {
  newItems.push({json: item});
}

return newItems;

```

but I have an error :

> ERROR: The json-property has to be an object! [Line 109]

Here is my output with just the array in Json:

 ![Capture d’écran 2022-11-22 à 09.50.29](https://europe1.discourse-cdn.com/n8n/original/3X/d/a/dafaf32d0338c7f83de911fbc88a4a6eb11de281.png)  
It’s fine but I wanted to have 3 elements on my next input node to be run 3 times

## Please share the workflow

If you could help me, thank you.

---

<div class="post-metadata">

**Author:** ![eldala07](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/eldala07/32/19349_2.png) [@eldala07](https://community.n8n.io/u/eldala07)\
**Post date:** [November 22, 2022, 9:30am UTC](https://community.n8n.io/t/return-function-response-as-multiple-items/20029/2 "2022-11-22T09:30:13Z")

</div>

Hello,

This is because you return an object instead of an array.

Here is the code I used:

```auto
var labelCategories = ["ClientPremium", "Relance", "AnnulationCommande"];

const newItems = labelCategories.map(el => ({json: {label: el}}));

return newItems;

```

And here is the workflow:

Hope it helps!!

---

<div class="post-metadata">

**Author:** ![Samuel\_Simonney](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/samuel_simonney/32/12166_2.png) [@Samuel\_Simonney](https://community.n8n.io/u/Samuel_Simonney)\
**Post date:** [November 22, 2022, 3:41pm UTC](https://community.n8n.io/t/return-function-response-as-multiple-items/20029/3 "2022-11-22T15:41:42Z")

</div>

Thank you very much for your help, it works well

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/system/32/195824_2.png) [@system](https://community.n8n.io/u/system)\
**Post date:** [February 20, 2023, 3:41pm UTC](https://community.n8n.io/t/return-function-response-as-multiple-items/20029/4 "2023-02-20T15:41:50Z")

</div>

Closed on February 20, 2023, 3:41pm UTC

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