Browse Source

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

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

* fix: add axios error info from response
CXM 3 years ago
parent
commit
72634ffe6e
1 changed files with 5 additions and 2 deletions
  1. 5 2
      src/utils/http/axios/Axios.ts

+ 5 - 2
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);
         });
     });