Function fetchApiSplit

  • Fetches the data from the given endpoint, but splits the request into multiple requests if the specified parameter is larger than max specified.

    Type Parameters

    Parameters

    • endpoint: S

      The endpoint to fetch from.

    • params: ExtractParams<S>

      The parameters to pass to the endpoint.

    • Optionalmax: Partial<{
          [K in string | number | symbol]: number
      }>

      The maximum number of items to pass to the endpoint.

    • transform: ((response: ExtractResponse<S>) => T) = ...

      A function that accepts the endpoint response and transforms it into the desired type.

    • OptionalrequestOptions: RequestOptions<boolean>

      Any additional options to pass to fetch.

    Returns Promise<T[]>

    The transformed response from the endpoint.

    const data = await fetchApiSplit(getV1gamesicons, { universeIds: [1, 2, 3, 4, 5] }, { universeIds: 100 }, (response) => response.data);
    console.log(data); // [[{ "targetId": 0, "state": "Completed", "imageUrl": "..." }], ...]