Scenarios keeps looping although it should stop

Describe the issue/error/question

Hello, I have a scenario that @RicardoE105 was kind enought to help me put together with his reply to my question here: Loop through pagination in HTTP node

I have fixed the scenario however I want to only loop a custom API from page 1 to page 5 (There are some 3 thousand pages in the api) and save the data to a spreadsheet.

However, after this is acomplished, my HTTP Request node starts again to loop through the pages non stop. What am i doing wrong, now? :thinking:

Please share the workflow

here’s a video too.

I’m running n8n on Vultr with docker

Thanks in advance for your advice!

Hey @th3liam ,
in your IF node you check if your fake-api response has the next url with ?page=5

Your first api request returns:


But your second for ?page=2 does not return a next page url;


This resets your loop to the first page thus looping forever.


As @marcus mentioned. The API I shared with you only has two pages to simulate pagination. Since you change the condition in the IF, which checks if there is more data, you get an infinity loop. You should be able to do it with the API you want to work with instead of the demo API.

1 Like

Thank you for your comments fellas!

The pagination in the actual custom API has over 1,000 pages. I fixed the infinite loop by editing the values in the IF node to stop when the value in “next” is equal to 5. ( I only wanted to loop though 5 pages) and in the node options I enabled “Execute once”