Skip to content

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.

T

PaginatedFetchFunction<T>

Function that fetches a single page of results

Promise<{ items: T[]; pageCount: number; totalCount: number; }>

Object containing all results and pagination metadata

const { items, pageCount, totalCount } = await paginateWithMetadata((cursor) =>
notion.blocks.children.list('page-id', { start_cursor: cursor })
);
console.log(`Fetched ${totalCount} blocks across ${pageCount} pages`);