qlin 5477885fdf refactor: 优化 request 插件 (#130)
* refactor: 优化 request 插件

* fix: errorHandler 的顺序控制问题'
2022-06-16 11:04:26 +08:00

18 lines
745 B
TypeScript

import { AxiosRequestConfig, AxiosResponse } from 'axios';
type RequestInterceptor = (value: AxiosRequestConfig) => AxiosRequestConfig | [(value: AxiosRequestConfig) => AxiosRequestConfig, (error: any) => any];
type ResponseInterceptor = (value: AxiosResponse) => AxiosResponse | [(value: AxiosResponse) => AxiosResponse, (error: any) => any];
export interface RequestRuntimeConfig {
request: {
responseDataAdaptor?<T>(data: T): T;
closeResDataCheck?: boolean;
requestInterceptors?: RequestInterceptor[];
responseInterceptors?: ResponseInterceptor[];
errorHandler?: {
[key: string]: (error: { response: AxiosResponse } | AxiosResponse) => void;
};
} & AxiosRequestConfig;
}