Issue with API query returning only first page of results

Hi - we're currently testing Retool and mostly liking what we see...

I'm not a developer, so asking this for one of my team, but we've got an issue with a Zendesk API call only returning the first page of data, and need to find a way to loop through the call for all pages.

Specifically, we're trying to retrieve data such as all open tickets (>500) and all users (>2000), but the query in retool is only pulling back the first 100 records or so.

We're trying to use some javascript for the page looping - I don't think the issue is specific to the Zendesk API, but the javascript code?

let pageNum = 1;
let allPages = [];

while(true){
const page = getUsers.trigger({additionalScope: {pageNum: pageNum}})

if(page.next_page?.length == 0){
break
}

allPages = allPages.concat(page);
pageNum++;
console.log(pageNum)
}

console.log(allPages.length)
return allPages

And the getUsers query is as follows:

Any help/suggestions would be much appreciated!!

TIA, Nick

Hey @nickwarren!

If you're using additionalScope you don't need to access the value property on the variable, you can just reference {{ pageNum }} and it should resolve to the correct value when the query is triggered from your script. Can you let me know if that works?

Thanks - that's helped...!!