I’m hitting a wall with the Genesys Cloud Platform SDK for JavaScript (v3.1.0). The goal is to fetch all queues across every division in our org to build a local cache for our Android app’s backend service. The QueuesApi.listQueues() method returns a PaginationResponse, but I’m struggling to chain the pagination calls correctly when divisionId isn’t specified.
Here’s the current approach:
const listAllQueues = async (apiClient) => {
const allQueues = [];
let nextPageUri = '/api/v2/iam/queues';
while (nextPageUri) {
const response = await apiClient.queuesApi.listQueues({
pageSize: 200,
divisionId: null // Intentionally null to get all
});
allQueues.push(...response.entities);
nextPageUri = response.nextPageUri;
}
return allQueues;
};
The issue is that nextPageUri seems to nullify after the first page even though the response headers indicate more data exists. If I hardcode a specific divisionId, pagination works as expected. Without it, the SDK appears to stop iterating prematurely. I’ve checked the raw HTTP response and the Link header is present, but the SDK’s internal parser might be ignoring it when the division scope is global.
Is there a recommended pattern for handling global resource pagination in this SDK? Or should I be fetching divisions first and then looping through listQueues for each divisionId? The latter feels inefficient given the API supports global queries. Any insights on the SDK’s pagination logic for unscoped calls would be helpful. I’ve spent hours debugging this loop and it just feels like I’m missing a flag or a method override.