Represents the parameters for an API handler.

interface IApiHandlerParams<Data extends IAnything = IAnything> {
    abortSignal?: AbortSignal;
    fallback?: (e: Error) => void;
    fetch?: (input: URL | RequestInfo, init?: RequestInit) => Promise<Response> & (
        input: URL | RequestInfo,
        init?: RequestInit,
    ) => Promise<Response>;
    fetchParams?: () => RequestInit;
    onLoadBegin?: () => void;
    onLoadEnd?: (isOk: boolean) => void;
    origin?: string;
    requestMap?: (url: URL) => URL;
    responseMap?: (
        json: Data,
    ) => Record<string, any> | Promise<Record<string, any>>;
    withAbortSignal?: boolean;
}

Type Parameters

Properties

abortSignal?: AbortSignal
fallback?: (e: Error) => void
fetch?: (input: URL | RequestInfo, init?: RequestInit) => Promise<Response> & (
    input: URL | RequestInfo,
    init?: RequestInit,
) => Promise<Response>

Type declaration

    • (input: URL | RequestInfo, init?: RequestInit): Promise<Response>
    • Parameters

      • input: URL | RequestInfo
      • Optionalinit: RequestInit

      Returns Promise<Response>

    • (input: URL | RequestInfo, init?: RequestInit): Promise<Response>
    • Parameters

      • input: URL | RequestInfo
      • Optionalinit: RequestInit

      Returns Promise<Response>

fetchParams?: () => RequestInit
onLoadBegin?: () => void
onLoadEnd?: (isOk: boolean) => void
origin?: string
requestMap?: (url: URL) => URL
responseMap?: (json: Data) => Record<string, any> | Promise<Record<string, any>>
withAbortSignal?: boolean