Skip to content

Commit 6b75209

Browse files
chore(internal): fix pagination internals not accepting option promises
1 parent 834599b commit 6b75209

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/client.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -592,17 +592,22 @@ export class Finch {
592592
getAPIList<Item, PageClass extends Pagination.AbstractPage<Item> = Pagination.AbstractPage<Item>>(
593593
path: string,
594594
Page: new (...args: any[]) => PageClass,
595-
opts?: RequestOptions,
595+
opts?: PromiseOrValue<RequestOptions>,
596596
): Pagination.PagePromise<PageClass, Item> {
597-
return this.requestAPIList(Page, { method: 'get', path, ...opts });
597+
return this.requestAPIList(
598+
Page,
599+
opts && 'then' in opts ?
600+
opts.then((opts) => ({ method: 'get', path, ...opts }))
601+
: { method: 'get', path, ...opts },
602+
);
598603
}
599604

600605
requestAPIList<
601606
Item = unknown,
602607
PageClass extends Pagination.AbstractPage<Item> = Pagination.AbstractPage<Item>,
603608
>(
604609
Page: new (...args: ConstructorParameters<typeof Pagination.AbstractPage>) => PageClass,
605-
options: FinalRequestOptions,
610+
options: PromiseOrValue<FinalRequestOptions>,
606611
): Pagination.PagePromise<PageClass, Item> {
607612
const request = this.makeRequest(options, null, undefined);
608613
return new Pagination.PagePromise<PageClass, Item>(this as any as Finch, request, Page);

0 commit comments

Comments
 (0)