use-axios-http-requests-ts
Version:
Incredibly useful package for making HTTP requests! This package eliminates the need for the Fetch API and is built on top of the powerful library [axios](https://www.npmjs.com/package/axios).
19 lines (18 loc) • 679 B
TypeScript
import { AxiosRequestConfig } from "axios";
import { AxiosApiResponse, ErrorType } from "../types/types";
declare const useAxios: <ApiResponse = AxiosApiResponse>(url: string, dependencies?: any[], options?: AxiosRequestConfig) => {
data: ApiResponse | null;
loading: boolean;
refetching: () => void;
error: ErrorType | null;
reset: () => void;
};
declare const useAxiosFn: <ApiResponse>(url: string, options: AxiosRequestConfig, dependencies?: any[]) => {
data: ApiResponse | null;
loading: boolean;
refetching: () => void;
error: ErrorType | null;
execute: () => Promise<void>;
reset: () => void;
};
export { useAxios, useAxiosFn };