I am trying to paginate a HTTP API (swapi.dev) and it works for the 1st loop (Loop Over Items) where the names are displayed in console properly. Then on the 2nd “next” run, the Loop Over Items node simply passes the control to the If node without executing the loop. All subsequent next executions move straight to the if node without looping.
What is the error message (if any)?
No error messages.
Please share your workflow
(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)
Share the output returned by the last node
I stop the workflow when I see that loop is not working.
Information on your n8n setup
n8n version: Latest
Database (default: SQLite):
n8n EXECUTIONS_PROCESS setting (IDK so I guess Default):
Thanks for posting here and welcome to the community!
When sharing your workflow’s JSON make sure to surround them with the backticks, like so:
``` // your json goes here ````
I formatted your initial post for better visibility
In regards to your looping issue:
I was able to re-create your workflow and it looks fine to me, looping until there’s no tomorrow!
So I am wondering whether it could be due to memory restrictions on your end. Did you get any error messages, like below?
The problem is that the Loop for Items only loops 1 time i.e. for the 1st list I receive from API. All the subsequent executions pass directly to the If block.
See the image:
1st API Response: The “Loop for Items” executes the loop printing the names in the console.
2nd and subsequent response: Passes directly to the If block without printing the names.
That’s because you can’t use Loop over items node within the external “Loop” (linking back the Code1 node), as both the Loop node and that backlinking operate with the workflow’s $runIndex property, which then breaks the next Loop over items run.
In your case, you should move the Loop Over items node functionality to the sub-workflow, so your main workflow will be like this:
and sub-workflow (you actually don’t need a Loop node here, but you may use it as well):
The Aggregate node is needed to output only one item (another option - use No Operation Node with the option “Execute Once”