vue-vben-admin/src/utils/http/axios/axiosTransform.ts

44 lines
1.2 KiB
TypeScript
Raw Normal View History

2020-09-28 20:19:10 +08:00
/**
2021-02-26 22:45:36 +08:00
* Data processing class, can be configured according to the project
2020-09-28 20:19:10 +08:00
*/
import type { AxiosRequestConfig, AxiosResponse } from 'axios';
import type { RequestOptions, Result } from './types';
export abstract class AxiosTransform {
/**
2021-02-26 22:45:36 +08:00
* @description: Process configuration before request
2020-09-28 20:19:10 +08:00
* @description: Process configuration before request
*/
beforeRequestHook?: (config: AxiosRequestConfig, options: RequestOptions) => AxiosRequestConfig;
/**
2021-02-26 22:45:36 +08:00
* @description: Request successfully processed
2020-09-28 20:19:10 +08:00
*/
2021-02-26 22:45:36 +08:00
transformRequestHook?: (res: AxiosResponse<Result>, options: RequestOptions) => any;
2020-09-28 20:19:10 +08:00
/**
* @description:
*/
2021-02-26 22:45:36 +08:00
requestCatchHook?: (e: Error) => Promise<any>;
2020-09-28 20:19:10 +08:00
/**
* @description:
*/
requestInterceptors?: (config: AxiosRequestConfig) => AxiosRequestConfig;
/**
* @description:
*/
responseInterceptors?: (res: AxiosResponse<any>) => AxiosResponse<any>;
/**
* @description:
*/
requestInterceptorsCatch?: (error: Error) => void;
/**
* @description:
*/
responseInterceptorsCatch?: (error: Error) => void;
}