UNPKG

use-invariant

Version:

- <a target="_blank" rel="noopener noreferrer" href='https://codesandbox.io/s/usefetch-in-nextjs-nn9fm'>Example - Next.js</a> - <a target="_blank" rel="noopener noreferrer" href='https://codesandbox.io/embed/km04k9k9x5'>Examples - create-react-app</a>

38 lines (37 loc) 1.23 kB
export declare enum HTTPMethod { DELETE = "DELETE", GET = "GET", HEAD = "HEAD", OTIONS = "OPTIONS", PATCH = "PATCH", POST = "POST", PUT = "PUT" } export interface Options { url?: string; onMount?: boolean; method?: string; timeout?: number; baseUrl?: string; } export declare type FetchData = (fArg1?: string | object | undefined, fArg2?: string | object | undefined) => Promise<void>; export declare type FetchCommands = { get: FetchData; post: FetchData; patch: FetchData; put: FetchData; del: FetchData; delete: FetchData; query: (query?: string | undefined, variables?: object | undefined) => Promise<void>; mutate: (mutation?: string | undefined, variables?: object | undefined) => Promise<void>; abort: () => void; }; export declare type DestructuringCommands<TData = any> = [TData | undefined, boolean, any, FetchCommands]; export declare type UseFetchResult<TData = any> = FetchCommands & { data?: TData; loading: boolean; error?: any; request: FetchCommands; }; export declare type useFetchArg1 = string | Options & RequestInit; export declare type UseFetch<TData> = DestructuringCommands<TData> & UseFetchResult<TData>;