import type { PluginDefinition, Request } from '../types'; /** * catch error options */ export type CatchErrorOptions = { /** * when error in response.body * throw error to handler with `Promise.reject(error)` * @deprecated axios use interceptors.response.use to change response type would cause an error, use `serializerResponse` instead. */ serializerData?: (data: T) => R | Promise; /** * when error in response.body, example: {code: 0, message: 'error message'} * throw error to handler with `Promise.reject(error)` * @param response * @returns */ serializerResponse?: (response: T) => R | Promise; /** * error catch handler */ handler?: (error: any) => Promise; }; /** * regist catch error plugin on current promise request * @param request request promise * @param options catch error options */ export declare function registCatchError(request: Request, options?: CatchErrorOptions): Request; /** * 注册异常处理插件 * 只在regist apis上运行 (and 自定义条件下) * @param options 插件配置 */ export declare const createCatchErrorPlugin: PluginDefinition; declare module '../types' { interface RequestCustomConfig { /** * enable catch error * or catch error by Promise.catch locally * @default false */ catchError?: boolean; } }