use-minimal-fetch
Version:
A lightweight useFetch hook with Axios wrapper for React apps
16 lines (15 loc) • 413 B
TypeScript
type Method = "get" | "post" | "put" | "patch" | "delete";
interface ApiOptions {
method?: Method;
lazy?: boolean;
params?: Record<string, any>;
headers?: Record<string, string>;
body?: any;
}
export declare const useApi: <T = any>(url: string, options?: ApiOptions) => {
data: T | null;
loading: boolean;
error: any;
execute: (overrideBody?: any) => Promise<T>;
};
export {};