Returning a array from Code Node - A 'json' property isn't an object

Describe the problem/error/question

A code node with just this line -
return ['1','2','3','4'];
gives me a error “A ‘json’ property isn’t an object”

What is the error message (if any)?

“A ‘json’ property isn’t an object”

Returning an array is useful to use a batch node following the code node, or let the default n8n behavior where it runs the next node once for each item automatically (e.g save them to a database).

This used to be working in the 0.9.* versions before I recently upgraded to 1.1 version.

I hope it is still possible to return an array from a code node, and I am missing something small/obvious here.

Any help is appreciated, Thanks !

Information on your n8n setup

  • n8n version: 1.1.1
  • Running n8n via Docker compose

Hey @atomtr,

To be honest I would expect that to fail even in 0.2.x as we expect the data to be JSON, If you were to do something like…

return [{id:'1'},{id:'2'},{id:'3'},{id:'4'}];

That would return an array and give you 4 items so the next node would run 4 times.

1 Like

Thanks for that @Jon - I guess I must have been on an even older version and now have updated my workflow to return proper json objects. Cheers


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