Function Node: Access all items from previous node output

I have a Workflow that goes something like this:

  1. Run
  2. Get Tasks: HTTP Request
  3. Filter Tasks: Function
  4. Get Folders: HTTP Request
  5. Filter Folders: Function
  6. Combine Tasks and Folders: Function

In step 6, I need to use the output from both 5 and 3. 5 is just items, so that’s fine. But, I’m having trouble getting all of the output from 3.

I’ve tried $node["Filter Tasks"].json which only gives me the first item. I’ve also tried $item(0).$node["Filter Tasks"].json, which gives me the same thing. $item(1).$node["Filter Tasks"].json gives me the second item. But, since I don’t know how many items are returned in that node, I can’t just get $item(0), $item(1), etc.

I can’t figure out how I just get all of the items from the “Filter Tasks” node, and I don’t see anything in https://docs.n8n.io/nodes/n8n-nodes-base.function/#node-reference or https://docs.n8n.io/reference/javascript-code-snippets.html#date-and-time that tells me.

You can use $items(). So in your case that would be:

const allItems = $items("Filter Tasks");

You can find the documentation here:

1 Like

Thank you so much! That link is very helpful.

Great to hear! Have fun!