/** * 对Axios进行了封装 * 1. 接口错误拦截 请求本身异常 或 服务端报错 均会触发catch 自动调用notify进行提示 * 本次请求response返回null 可以在config中配置 noNotify 禁用自动错误提示 * 2. 可以在config中添加catcher函数 处理异常 * 3. config 加上encode 会自动encode params */ import { AxiosResponse, AxiosRequestConfig, AxiosError } from 'axios'; export declare type RequestResponse = null | AxiosResponse; export declare type RequestConfig = { /** * @description 关闭默认错误提示 */ noNotify?: boolean; /** * @description 异常处理器 */ catcher?: (err: RequestError) => RequestResponse; /** * @description response处理器 */ transformResponse?: (data: Data) => Data; /** * @description params参数格式 */ params?: { [propName: string]: any; }; /** * @description 是否对params进行encodeURLComponent */ encode?: true; } & AxiosRequestConfig; export declare type RequestError = AxiosError & { config: RequestConfig; }; export declare const del: (url: string, payload?: any, config?: RequestConfig) => Promise>; export declare const get: (url: string, payload?: any, config?: RequestConfig) => Promise>; export declare const put: (url: string, payload?: any, config?: RequestConfig) => Promise>; export declare const post: (url: string, payload?: any, config?: RequestConfig) => Promise>; export declare const patch: (url: string, payload?: any, config?: RequestConfig) => Promise>;