index.ts 720 B

12345678910111213141516171819202122232425262728293031
  1. import type {
  2. InternalAxiosRequestConfig,
  3. AxiosResponse,
  4. AxiosRequestConfig,
  5. AxiosInstance,
  6. AxiosRequestHeaders,
  7. AxiosError
  8. } from 'axios'
  9. interface RequestInterceptors<T> {
  10. // 请求拦截
  11. requestInterceptors?: (config: InternalAxiosRequestConfig) => InternalAxiosRequestConfig
  12. requestInterceptorsCatch?: (err: any) => any
  13. // 响应拦截
  14. responseInterceptors?: (config: T) => T
  15. responseInterceptorsCatch?: (err: any) => any
  16. }
  17. interface RequestConfig<T = AxiosResponse> extends AxiosRequestConfig {
  18. interceptors?: RequestInterceptors<T>
  19. }
  20. export {
  21. AxiosResponse,
  22. RequestInterceptors,
  23. RequestConfig,
  24. AxiosInstance,
  25. InternalAxiosRequestConfig,
  26. AxiosRequestHeaders,
  27. AxiosError
  28. }