Type alias ReturnFetchDefaultOptions

ReturnFetchDefaultOptions: {
    baseUrl?: string | URL;
    fetch?: ReturnType<ReturnFetch>;
    headers?: HeadersInit;
    interceptors?: {
        request?: ((requestArgs, fetch) => Promise<FetchArgs>);
        response?: ((response, requestArgs, fetch) => Promise<Response>);
    };
}

Options of returnFetch function.

Type declaration

  • Optional baseUrl?: string | URL

    Base URL of fetch. It will be used when the first argument of fetch is relative URL.

  • Optional fetch?: ReturnType<ReturnFetch>

    fetch function to be used in returnFetch function. If not provided, fetch function in global scope will be used. Any fetch implementation can be used, such as node-fetch, cross-fetch, isomorphic-fetch, etc.

    a fetch function created by returnFetch also can be used here.

  • Optional headers?: HeadersInit

    Default headers of fetch. It will be used when the second argument of fetch does not have headers property. If it is provided and headers also provided when calling a fetch, headers will be merged. Priority of headers is requestInit.headers > defaultOptions.headers. Duplicated headers will be overwritten.

  • Optional interceptors?: {
        request?: ((requestArgs, fetch) => Promise<FetchArgs>);
        response?: ((response, requestArgs, fetch) => Promise<Response>);
    }
    • Optional request?: ((requestArgs, fetch) => Promise<FetchArgs>)
    • Optional response?: ((response, requestArgs, fetch) => Promise<Response>)
        • (response, requestArgs, fetch): Promise<Response>
        • Response interceptor. It will be called after response.

          Parameters

          Returns Promise<Response>

Generated using TypeDoc