react-native-hook-api-call
Version:
Custom React Native hook for API calls using axios
15 lines (14 loc) • 542 B
TypeScript
import { AxiosInstance } from 'axios';
type HttpMethod = 'get' | 'post' | 'put' | 'delete';
interface UseApiOptions {
manual?: boolean;
params?: Record<string, any>;
}
declare function useApi<T = any>(endpoint: string, method: HttpMethod | undefined, options: UseApiOptions | undefined, axiosInstance: AxiosInstance): {
data: T | null;
loading: boolean;
error: string | null;
refetch: (payload?: Record<string, any>) => Promise<void>;
LoaderComponent: import("react").JSX.Element | null;
};
export default useApi;