Platform SDK JS: fetchQueues pagination across divisions

Does anyone know how to iterate through all divisions to fetch queues using the Platform SDK for JavaScript? The documentation implies a simple call, but I am hitting limits.

The fetchQueues method retrieves queues for the current user’s division only. Use fetchDivisions to iterate.

I am stuck on the async flow. My code:

const divisions = await platformClient.organizations.divisions.getAllDivisions();
// How to map and flatten queue results per divisionId?

Standard Promise.all fails due to rate limits. Need a robust pattern for bulk retrieval without 429 errors.

Check your rate limiting headers before blasting the API. I hit similar limits in ServiceNow webhooks. Here is a safe pattern:

const queues = [];
for (const div of divisions) {
 const res = await platformClient.queuesApi.getQueues({ divisionId: div.id });
 queues.push(...res.entities);
 await new Promise(r => setTimeout(r, 200)); // throttle
}

Avoid synchronous loops without delays.

Check your divisionId parameter. The suggestion above uses getQueues which is not the standard SDK method name for the async flow described.

In .NET I use GetQueuesAsync with divisionId. Here is the pattern:

var queues = await platformClient.QueueApi.GetQueuesAsync(divisionId: div.Id);

Have you tried combining Promise.all with division iteration? The suggestion above lacks error handling for rate limits. My flow uses structured message lookups similarly.

const queues = await Promise.all(divisions.map(d => platformClient.queuesApi.getQueues({ divisionId: d.id })));

See docs.

I’d recommend looking at at the concurrency implications of the Promise.all approach suggested above. While it appears efficient, executing simultaneous REST calls against /api/v2/queues for every division will inevitably trigger HTTP 429 Too Many Requests responses. The Genesys Cloud API enforces strict rate limits per tenant, and parallel execution ignores these constraints. You must implement a serialized flow with explicit error trapping to ensure the application does not crash or receive partial data sets due to throttling.

A robust pattern involves iterating through divisions sequentially with a retry mechanism for failed requests. This ensures that if one division returns an error, the loop continues without halting the entire process. You should also validate the divisionId existence before making the call to avoid unnecessary overhead. The following snippet demonstrates a safe, sequential approach with basic error handling.

const allQueues = [];
for (const div of divisions) {
 try {
 const res = await platformClient.queuesApi.getQueues({ divisionId: div.id });
 allQueues.push(...res.entities);
 } catch (err) {
 console.error(`Failed to fetch queues for division ${div.id}:`, err);
 }
}