Skip to content

iterateCursorPages

iterateCursorPages<T>(fetchPage): AsyncGenerator<T>

Defined in: packages/core/src/pagination/PaginationHelper.ts:159

Async generator for memory-efficient iteration over cursor-paginated results.

Used with Confluence v2 endpoints that return a _links.next URL instead of an offset. Yields one item at a time and extracts the cursor from the next link automatically. Stops when there is no next link.

T

(cursor?) => Promise<CursorPage<T>>

A function that fetches one page; receives undefined for the first page and a cursor string for subsequent pages

AsyncGenerator<T>

import { iterateCursorPages } from '@forge-clients/core';
import { getPages } from '@forge-clients/confluence/v2';
for await (const page of iterateCursorPages(
(cursor) => getPages(client, { query: { spaceKey: 'MYSPACE', cursor } }),
)) {
console.log(page.title);
}