react-js-plugins
Version:
A powerful and efficient React utility library designed to enhance application performance by streamlining and simplifying the management of complex asynchronous operations.
42 lines (41 loc) • 1.53 kB
TypeScript
import { AxiosInstance, AxiosRequestConfig, AxiosResponse, AxiosError } from 'axios';
declare module 'axios' {
interface AxiosRequestConfig {
enableEncrypt?: boolean;
enableDecrypt?: boolean;
enableUpload?: boolean;
enableDownload?: boolean;
requestDataType?: any;
responseDataType?: any;
enablePrivateMode?: boolean;
enableLoader?: boolean;
}
}
interface AxiosConfigProps {
baseURL: string;
timeout?: number;
withCredentials?: boolean;
enableDateTransform?: boolean;
enablePrivateMode?: boolean;
enableLoader?: boolean;
getToken?: () => string | null;
handleAuthError?: (axiosInstance: AxiosInstance, originalRequest: AxiosRequestConfig, err: AxiosError) => Promise<AxiosResponse>;
transformRequest?: (params: {
data: any;
config: AxiosRequestConfig;
}) => any;
transformResponse?: (params: {
data: any;
config: AxiosRequestConfig;
status: number;
headers: any;
}) => any;
defaultHeaders?: Record<string, string>;
onError?: (error: AxiosError) => void;
onLoaderChange?: (params: {
isLoading: boolean;
config?: AxiosRequestConfig;
}) => void;
}
export declare const createAxiosInstance: ({ baseURL, timeout, withCredentials, enableDateTransform, enablePrivateMode, enableLoader, getToken, handleAuthError, transformRequest, transformResponse, defaultHeaders, onError, onLoaderChange, }: AxiosConfigProps) => AxiosInstance;
export {};