New function / code node - splitting array into multiple JSON items

Hey guys,

There are many templates for splitting arrays into JSON items that no longer work with the new Function node: n8n.io - Workflow Automation

What would be the easiest way to adjust the code?

Thanks!

Hi @jonas, it’s important to understand that these templates will still work. You are still able to execute the old Function node in your existing workflows. You’d only get a note saying the Code is now available but this should not stop the workflow from executing:

As for the example template specifically, it would process a data structure the HTTP Request node would have returned in the past. These days the HTTP Request node should split out such data structures automatically into individual n8n items, so you can most likely ignore this specific template.

Putting all these points aside and assuming you absolutely want to run the transformation code snippet in the Code node you can still do this:

n8n will highlight item here as a possible error as this is also the name of a default n8n variable not available in this context. But since it’s used here in the context of a .map() method you can just ignore that and still run your code on the current 0.209.3 version of n8n.

So no adjustment is needed here, though you could rename item to something else if you want to in order to get rid of the linting errors.