Skip to content

PagePromise

Defined in: src/core/pagination.ts:19

Return type of every paginated SDK method — both a promise and an iterator:

  • await client.vendors.list() → the first page;
  • for await (const vendor of client.vendors.list()) → every item, across pages, following next_cursor automatically;
  • for await (const page of client.vendors.list().pages()) → page-by-page.

Each await/iteration starts its own request(s).

P extends PageShape

  • PromiseLike<P>
  • AsyncIterable<PageItem<P>>

new PagePromise<P>(fetchPage): PagePromise<P>

Defined in: src/core/pagination.ts:24

(cursor?) => Promise<P>

PagePromise<P>

[asyncIterator](): AsyncGenerator<PageItem<P>, void, undefined>

Defined in: src/core/pagination.ts:47

Iterate every item across all pages.

AsyncGenerator<PageItem<P>, void, undefined>

AsyncIterable.[asyncIterator]


pages(): AsyncGenerator<P, void, undefined>

Defined in: src/core/pagination.ts:37

Iterate page-by-page, following next_cursor until exhausted.

AsyncGenerator<P, void, undefined>


then<TResult1, TResult2>(onfulfilled?, onrejected?): Promise<TResult1 | TResult2>

Defined in: src/core/pagination.ts:29

Attaches callbacks for the resolution and/or rejection of the Promise.

TResult1 = P

TResult2 = never

((value) => TResult1 | PromiseLike<TResult1>) | null

The callback to execute when the Promise is resolved.

((reason) => TResult2 | PromiseLike<TResult2>) | null

The callback to execute when the Promise is rejected.

Promise<TResult1 | TResult2>

A Promise for the completion of which ever callback is executed.

PromiseLike.then