Function fetchApiPagesGenerator

  • Fetches all pages of results for the given endpoint and parameters. This is a generator function that yields each page as it is fetched.

    Type Parameters

    Parameters

    • endpoint: S

      The endpoint to fetch.

    • initialParams: ExtractParams<S>

      The initial parameters to use for the endpoint.

    • OptionalrequestOptions: RequestOptions<R>

      The options to use when making requests.

    • limit: number = 1000

      The maximum number of pages to fetch.

    Returns AsyncGenerator<ExtractResponse<S>, void, unknown>

    An array of all results.

    The next page of results.

    const pages = fetchApiPagesGenerator(getV1badgesicons, { badgeIds: [1, 2, 3] });
    for await (const page of pages) {
    console.log(page.data);
    }