infinity-fetch - v1.5.0
    Preparing search index...

    Type Alias PageFetchConfig<TResponse, TItem, TOut>

    PageFetchConfig: PaginationOptions<TResponse, TItem, TOut> & {
        fetcher: (
            params: PageParams,
            context: FetchContext,
        ) => Promise<TResponse>;
        getItems: (response: TResponse) => TItem[] | Promise<TItem[]>;
        startPage?: number;
        perPage?: number;
        getTotalPages?: (response: TResponse) => number | null | undefined;
        isLastPage?: (response: TResponse, items: TItem[], page: number) => boolean;
    }

    Type Parameters

    • TResponse
    • TItem
    • TOut = TItem

    Type Declaration

    • fetcher: (params: PageParams, context: FetchContext) => Promise<TResponse>
    • getItems: (response: TResponse) => TItem[] | Promise<TItem[]>

      Extracts items from a single page response. May be async

    • OptionalstartPage?: number

      First page number. Defaults to 1

    • OptionalperPage?: number

      Items per page. Defaults to 100

    • OptionalgetTotalPages?: (response: TResponse) => number | null | undefined

      Optional: total number of pages, read from the response. Stops once it is reached

    • OptionalisLastPage?: (response: TResponse, items: TItem[], page: number) => boolean

      Optional: custom last-page check. Defaults to "the page returned fewer items than perPage".