hook-fetch
Version:
A lightweight and modern HTTP request library developed based on the native Fetch API of the browser, providing a user-friendly interface similar to Axios and powerful extensibility.
26 lines (25 loc) • 1.17 kB
TypeScript
import { ResponseError, StreamContext } from "../types-DKk321dw.js";
import { HookFetchRequest$1 as HookFetchRequest } from "../index-C-WVDJU7.js";
import * as react0 from "react";
//#region src/react/index.d.ts
interface UseHookFetchOptions<Q extends (...args: any[]) => any> {
request: Q;
onError?: (e: Error) => any;
}
declare function useHookFetch<Q extends (...args: any[]) => any>({
request,
onError
}: UseHookFetchOptions<Q>): {
request: (...args: any[]) => HookFetchRequest<any, any> | react0.RefObject<HookFetchRequest<any, any> | null>;
stream: <T = unknown>(...args: Parameters<Q>) => AsyncGenerator<StreamContext<null> | StreamContext<T>, ResponseError<unknown> | undefined, unknown>;
text: (...args: Parameters<Q>) => Promise<string>;
blob: (...args: Parameters<Q>) => Promise<Blob>;
arrayBufferData: (...args: Parameters<Q>) => Promise<ArrayBuffer>;
formDataResult: (...args: Parameters<Q>) => Promise<FormData>;
bytesData: (...args: Parameters<Q>) => Promise<Uint8Array<ArrayBufferLike>>;
cancel: () => void;
loading: boolean;
setLoading: react0.Dispatch<react0.SetStateAction<boolean>>;
};
//#endregion
export { useHookFetch };