collectAllPages
collectAllPages<
T>(fetchPage,pageSize?):Promise<T[]>
Defined in: packages/core/src/pagination/PaginationHelper.ts:69
Collect all pages of an offset-paginated endpoint into a single array.
Fetches pages sequentially until the last page is reached, then returns all items concatenated. For large result sets, prefer iteratePages to avoid loading everything into memory at once.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”fetchPage
Section titled “fetchPage”(startAt, maxResults) => Promise<OffsetPage<T>>
A function that fetches one page given startAt and maxResults
pageSize?
Section titled “pageSize?”number = 50
Number of items to request per page (default: 50)
Returns
Section titled “Returns”Promise<T[]>
Example
Section titled “Example”import { collectAllPages } from '@forge-clients/core';import { searchForIssuesUsingJql } from '@forge-clients/jira/v3';
const allIssues = await collectAllPages( (startAt, maxResults) => searchForIssuesUsingJql(client, { body: { jql: 'project = PROJ', startAt, maxResults } }),);console.log(`Found ${allIssues.length} issues`);