UNPKG

@finagraph/strongbox-finconnect-react

Version:

React components to integrate with Finagraph Strongbox

33 lines (32 loc) 1.38 kB
export declare enum FetchMethod { Delete = "DELETE", Get = "GET", Patch = "PATCH", Post = "POST", Put = "PUT" } export declare class FetchError extends Error { errorMessage: string | undefined; status: number; errors: Record<string, string[]> | undefined; constructor(message: string, errorMessage: string | undefined, status: number, errors?: Record<string, string[]>); } /** Global configuration for FetchWrapper */ export type FetchWrapperOptions = { /** * Error handler that will be invoked when a FetchError is thrown. If this promise does not reject, * FetchWrapper will not throw an error. */ errorHandler?: (error: FetchError | Error) => Promise<void>; }; export declare const fetchWrapperOptions: FetchWrapperOptions; /** * A wrapper around fetch, including error handling of bad status codes and inclusion * of common headers. * @param url Url to fetch. * @param init Request options. * @param jsonHeaders If set, json headers will be added to the request. * @param requireAuth If set, authorization headers will be added to the request. * @param noCache If set, no-cache headers are added to the request. */ export declare function fetchWrapper(url: string, init?: Partial<RequestInit>, jsonHeaders?: boolean, requireAuth?: boolean, noCache?: boolean): Promise<Response>;