Pagination looping and the IF node

Describe the problem/error/question

Hi, Im trying to make a flow that loops through a lot of pages within n8n. I made a demo and use a free API of Game of thrones to illustrate the problem as I cannot share my own HTTPS node and results.

  • I first count how many items there are (not in the workflow, I just set an amount)
  • then Set the Offset to push to the API (not used in Demo API)
  • Then I speak to the API and get some results.
  • the IF Node checks if the Runidex is enough or not yet
  • It will loop the right amount and activate the true branch
  • Then the true branch activates. I lost all the items in the False Branch.

My Question is how to get these items back in the workflow and (preferabel) merge it in 1 run!?

I found several post about this but i cannot find the right answer for this.

Kind regards,


Please share your workflow

Share the output returned by the last node

Information on your n8n setup

  • n8n version: 1.1.1
1 Like

Can this have something to do with the excecution order? When I put the merge data earlier in the flow it seems to work, a little bit weird but it works

Hi @timautomation, I am sorry to hear you’re having trouble.

Btw, I really appreciate you providing an example workflow to demonstrate the problem. I know it’s sometimes hard to do especially where a non-public API is being used, but it makes it much easier to help.

The basic idea should still work, though it appears you are using slightly older node versions here. To simplify things I’ve removed the old HTTP Request and Function nodes and added fresh ones in their place just in case someone else stumbles across this.

The actual problem would be that you’re reading from the IF node in your code and are using an expression like $items("IF1", 0, counter). The If node has multiple outputs, but the 0 in this expression instructs n8n to read only from the first output. So you want to read from the “GOT Free API” node instead which has only one output. Here’s how it looks in a workflow based on this template:

This will provide you with the items from all your runs:

Hope this helps!


Thanks! this works! :slight_smile: Hope this thread will help more n8n users!

1 Like

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