ERROR: Code doesn't return items properly - Item Lists

Hey @altembergandrade,

You get the error because of the wrong usage of n8n-data. Every object that comes from a node has this basic structure:

{
   json: {
      att1: "att1",
      att2: "att2"
   }
}

That means for your solution you need to change the code in line 3 to

if(myArray[i].json.email === nameKey) {

A shorter and more precise way to achive your search would be

return $('Item Lists').all().filter(item => item.json.email === '[email protected]');

Keep in mind that this filtering can also result in not finding any entry. The normal behaviour of n8n in that case is that it stops the execution. You can change that in the settings of the node/or the workflow.

Cheers

4 Likes