export type FetchOptions = RequestInit & { /** * The base URL to prepend to all request endpoints. * If provided, it handles slash normalization automatically. */ baseUrl?: string; /** * Key-value pairs to be appended to the URL as a query string. */ params?: Record; /** * How to serialize arrays in query params: * 'repeat': ?tags=red&tags=blue * 'indices': ?tags[0]=red&tags[1]=blue * 'brackets': ?tags[]=red&tags[]=blue * @default 'indices' */ paramArrayMode?: 'repeat' | 'indices' | 'brackets'; /** * Explicitly define how to parse the response. * @default 'json' */ responseType?: 'json' | 'text' | 'blob' | 'arrayBuffer' | 'formData'; /** * Whether to trigger a global loading state/indicator. * Useful for showing progress bars or spinners in the UI via the FetchPlugin. */ loadingIndicator?: boolean; /** * If true, prevents multiple identical requests from being sent simultaneously. * Subsequent calls will return the same promise as the initial in-flight request. * @default true */ dedupe?: boolean; /** * Time-to-live for the response cache in milliseconds. * Set to 0 to disable caching for a specific request. * @default 0 */ cacheTTL?: number; }; export type FetchResponse = { data: T; status: number; statusText: string; headers: Headers; }; export declare class FetchError extends Error { readonly response: Response; readonly messages: string[]; constructor(response: Response, messages?: string[]); } export declare class FailedFetchError extends FetchError { constructor(); } export declare class FetchCanceledError extends FetchError { constructor(); } export declare function isFetchCanceledError(error: unknown): error is FetchCanceledError; export type FetchInstance = { send: (url: string, options?: FetchOptions) => Promise>; sendForm: (url: string, formData?: FormData, options?: FetchOptions) => Promise>; get: (url: string, options?: FetchOptions) => Promise>; post: (url: string, data?: any, options?: FetchOptions) => Promise>; postForm: (url: string, formData?: FormData, options?: FetchOptions) => Promise>; put: (url: string, data?: any, options?: FetchOptions) => Promise>; putForm: (url: string, formData?: FormData, options?: FetchOptions) => Promise>; patch: (url: string, data?: any, options?: FetchOptions) => Promise>; patchForm: (url: string, formData?: FormData, options?: FetchOptions) => Promise>; delete: (url: string, options?: FetchOptions) => Promise>; head: (url: string, options?: FetchOptions) => Promise>; options: (url: string, options?: FetchOptions) => Promise>; }; export declare function useFetch(defaultOptions?: FetchOptions): FetchInstance;