# Can't get SplitInBatches to work with Function node

**URL:** <https://community.n8n.io/t/cant-get-splitinbatches-to-work-with-function-node/2976>\
**Category:** Questions\
**Created:** [November 9, 2020, 6:45am UTC](https://community.n8n.io/t/cant-get-splitinbatches-to-work-with-function-node/2976 "2020-11-09T06:45:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![gravitoad](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/gravitoad/32/2246_2.png) [@gravitoad](https://community.n8n.io/u/gravitoad)\
**Post date:** [November 9, 2020, 6:45am UTC](https://community.n8n.io/t/cant-get-splitinbatches-to-work-with-function-node/2976/1 "2020-11-09T06:45:03Z")

</div>

I have a function Node, and by using the following code:

```
const PrintfulPayload = {
 
vars: items[0].json.vars
  
};

PrintfulPayload 

return [
  {
    json: PrintfulPayload 
  }
];

```

I am able to get:

```
[
   {
      "vars":[
         {
            "id":6834,
            "product_id":5,
           
         },
         {
            "id":6835,
            "product_id":5,
         }
      ]
   }
]

```

But the SplitInBatches seems to need the data without the array like:

```
[
   {
         {
            "id":6834,
            "product_id":5,
           
         },
         {
            "id":6835,
            "product_id":5,
            
         }
   }
]

```

If I try and get it without, like:

```
const PrintfulPayload = {
 
 
 items[0].json.vars
  
};

PrintfulPayload 

return [
  {
    json: PrintfulPayload 
  }
]; 

```

It throws an error. How do I get just a list of the array items?

---

<div class="post-metadata">

**Author:** ![harshil1712](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/harshil1712/32/1374_2.png) [@harshil1712](https://community.n8n.io/u/harshil1712)\
**Post date:** [November 9, 2020, 9:28am UTC](https://community.n8n.io/t/cant-get-splitinbatches-to-work-with-function-node/2976/2 "2020-11-09T09:28:16Z")

</div>

Hey @gravitoad!

The output from the Function node is returning an object which contains the array. The SplitInBatches node takes this as a single input and returns the whole object as the output. Instead of returning a single object, you want to return multiple objects. Similar to the following example

```nohighlight
[
         {
            "id":6834,
            "product_id":5,
           
         },
         {
            "id":6835,
            "product_id":5,
         }
]

```

Below is an example that might help. The first two function nodes are creating the mock data. You want to use the `Create JSON-items` function node.

Hope this helps! 🙂

---

<div class="post-metadata">

**Author:** ![gravitoad](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/gravitoad/32/2246_2.png) [@gravitoad](https://community.n8n.io/u/gravitoad)\
**Post date:** [November 9, 2020, 5:32pm UTC](https://community.n8n.io/t/cant-get-splitinbatches-to-work-with-function-node/2976/3 "2020-11-09T17:32:06Z")

</div>

That did the trick, thanks a bunch!

---

<div class="post-metadata">

**Author:** ![harshil1712](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/harshil1712/32/1374_2.png) [@harshil1712](https://community.n8n.io/u/harshil1712)\
**Post date:** [November 10, 2020, 7:33am UTC](https://community.n8n.io/t/cant-get-splitinbatches-to-work-with-function-node/2976/4 "2020-11-10T07:33:40Z")

</div>

I am happy that this worked! Have fun! 🙂
