paginateWithMetadata
paginateWithMetadata<
T>(fetchPage):Promise<{items:T[];pageCount:number;totalCount:number; }>
Defined in: src/helpers/pagination.helpers.ts:183
Collects all results. Returns the items together with pagination metadata.
Use this function when you need the page count or the total number of API calls.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”fetchPage
Section titled “fetchPage”Function that fetches a single page of results
Returns
Section titled “Returns”Promise<{ items: T[]; pageCount: number; totalCount: number; }>
Object containing all results and pagination metadata
Example
Section titled “Example”const { items, pageCount, totalCount } = await paginateWithMetadata((cursor) => notion.blocks.children.list('page-id', { start_cursor: cursor }));
console.log(`Fetched ${totalCount} blocks across ${pageCount} pages`);