Skip to main content

Function: paginate()

function paginate<T>(fetchPage: (cursor?: string) => Promise<Page<T>>): AsyncGenerator<T, void, void>;

Defined in: packages/sdk/src/pagination.ts:8

Walk a cursor-paginated endpoint, yielding every item across pages. The fetchPage callback receives the cursor for the next page (undefined for the first) and returns one page. Stops when nextCursor is null.

Type Parameters

Type Parameter
T

Parameters

ParameterType
fetchPage(cursor?: string) => Promise<Page<T>>

Returns

AsyncGenerator<T, void, void>