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.
25 lines (24 loc) • 1 kB
TypeScript
import { StreamContext } from "../types-DOFlmwin.js";
import { HookFetchRequest } from "../baseClass-BYjVeiZn.js";
import * as vue0 from "vue";
//#region src/vue/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>;
stream: <T = unknown>(...args: Parameters<Q>) => AsyncGenerator<StreamContext<null> | StreamContext<T>, void, 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: vue0.Ref<boolean, boolean>;
};
//#endregion
export { useHookFetch };