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

I’m trying to search for an object within JSON using a specific value.

If the JSON is inside the javascript code, it works. But when I use the code that comes from Item Lists, it gives an error.

Here’s an example of what I’m trying to do:

And here is the error that appears when I try to use the Item Lists information:

Information on your n8n setup

  • n8n version: 1.0.1
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

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] === nameKey) {

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

return $('Item Lists').all().filter(item => === '[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.



It solved my problem! Thanks @nico-kow

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