Browse Source

fix: add axios error info from response (#1083)

* fix(type): fix ant-design-vue  ->

* fix: add axios error info from response
pull/1087/head
CXM 5 years ago
committed by GitHub
parent
commit
72634ffe6e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      src/utils/http/axios/Axios.ts

7
src/utils/http/axios/Axios.ts

@ -1,4 +1,4 @@
import type { AxiosRequestConfig, AxiosInstance, AxiosResponse } from 'axios';
import type { AxiosRequestConfig, AxiosInstance, AxiosResponse, AxiosError } from 'axios';
import type { RequestOptions, Result, UploadFileParams } from '../../../../types/axios';
import type { CreateAxiosOptions } from './axiosTransform';
import axios from 'axios';
@ -220,11 +220,14 @@ export class VAxios {
}
resolve(res as unknown as Promise<T>);
})
.catch((e: Error) => {
.catch((e: Error | AxiosError) => {
if (requestCatchHook && isFunction(requestCatchHook)) {
reject(requestCatchHook(e, opt));
return;
}
if (axios.isAxiosError(e)) {
// rewrite error message from axios in here
}
reject(e);
});
});

Loading…
Cancel
Save