in src/core.ts [716:735]
async getNextPage(): Promise<this> {
const nextInfo = this.nextPageInfo();
if (!nextInfo) {
throw new OpenAIError(
'No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.',
);
}
const nextOptions = { ...this.options };
if ('params' in nextInfo && typeof nextOptions.query === 'object') {
nextOptions.query = { ...nextOptions.query, ...nextInfo.params };
} else if ('url' in nextInfo) {
const params = [...Object.entries(nextOptions.query || {}), ...nextInfo.url.searchParams.entries()];
for (const [key, value] of params) {
nextInfo.url.searchParams.set(key, value as any);
}
nextOptions.query = undefined;
nextOptions.path = nextInfo.url.toString();
}
return await this.#client.requestAPIList(this.constructor as any, nextOptions);
}