Merge Node Pagination: Can't merge the item batches into single batch

I’m struggling with a common pagination problem and I’m hoping someone can point me in the right direction, as I feel I’ve hit a wall.
My Goal:
I have a workflow that fetches all customers from the Stripe API. The API is paginated, returning 100 customers per page. My goal is to run a loop to get all the pages and then combine them into one single list, so I can process all the customers at once in a database node.
My Workflow:
I am using the standard n8n looping pattern, which works correctly to fetch all the pages:
A Loop Entry node starts the process.
An HTTP Request node queries …/v1/customers with a limit of 100.
An IF node checks if has_more is true.
The true path goes to a Code node that gets the starting_after ID from the last record and sends it back to the Loop Entry node.
The false path is where the loop should end.
The Problem:
I cannot find a reliable way to collect the data from every page. When the loop finishes, I can’t get all ~700-800 customers into a single batch.
I have tried several methods, but they all fail:
Using a Merge (Append) node after the loop results in my downstream nodes running multiple times on incomplete batches.
Trying to pass the collected data through the loop by adding it to the item seems to fail, as the data gets lost or overwritten on the next iteration. I always end up with only the results from the very last page.
It seems like there is a timing issue where the loop finishes and sends its separate page items before they can be properly aggregated. How can I build a “gate” that waits for every single page to be fetched before releasing the complete, combined list of all customers?

Information on your n8n setup

  • n8n version: 1.114.0
  • Database: (default: SQLite)
  • Running n8n via (Docker, npm, n8n cloud, desktop app): GCP VM Instance. Locally using via tunneling
  • Operating system: Win 11

Hello,I used this loop. Maybe it helps.

1 Like

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