I’m creating a flow which will paginate through a list of Notion page search results and count the number of results. The pagination part is working correctly but I’m trying to store the results in a Collect step and it’s only storing the latest array that was passed to it -
The contents of body.results is an array so I was expecting the Collect step to store each array of results and output the combined array once it finished.
Does the collect step only work in a For loop (I’m using this approach to create a loop instead) or am I doing something else wrong here?
In the evaluate block, we’re appending the first result to an empty list (in this case it should be appended to the first API call you make that has the first page instead of an empty list.
In the if block, if there are more results, we re-trigger the send request block and use the list as the input to the evaluate block on the next iteration so that the values accumulate.
otherwise once there are no more pages, display the accumulated list.
Let me know if you run into any issues with this approach.