Skip to content

Commit 5676b81

Browse files
chore(internal): fix pagination internals not accepting option promises
1 parent 85aabaa commit 5676b81

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

src/client.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -509,17 +509,22 @@ export class Grid {
509509
getAPIList<Item, PageClass extends Pagination.AbstractPage<Item> = Pagination.AbstractPage<Item>>(
510510
path: string,
511511
Page: new (...args: any[]) => PageClass,
512-
opts?: RequestOptions,
512+
opts?: PromiseOrValue<RequestOptions>,
513513
): Pagination.PagePromise<PageClass, Item> {
514-
return this.requestAPIList(Page, { method: 'get', path, ...opts });
514+
return this.requestAPIList(
515+
Page,
516+
opts && 'then' in opts ?
517+
opts.then((opts) => ({ method: 'get', path, ...opts }))
518+
: { method: 'get', path, ...opts },
519+
);
515520
}
516521

517522
requestAPIList<
518523
Item = unknown,
519524
PageClass extends Pagination.AbstractPage<Item> = Pagination.AbstractPage<Item>,
520525
>(
521526
Page: new (...args: ConstructorParameters<typeof Pagination.AbstractPage>) => PageClass,
522-
options: FinalRequestOptions,
527+
options: PromiseOrValue<FinalRequestOptions>,
523528
): Pagination.PagePromise<PageClass, Item> {
524529
const request = this.makeRequest(options, null, undefined);
525530
return new Pagination.PagePromise<PageClass, Item>(this as any as Grid, request, Page);

0 commit comments

Comments
 (0)