未验证 提交 72634ffe 编写于 作者: C CXM 提交者: GitHub

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

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

* fix: add axios error info from response
上级 c420174c
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 { RequestOptions, Result, UploadFileParams } from '../../../../types/axios';
import type { CreateAxiosOptions } from './axiosTransform'; import type { CreateAxiosOptions } from './axiosTransform';
import axios from 'axios'; import axios from 'axios';
...@@ -220,11 +220,14 @@ export class VAxios { ...@@ -220,11 +220,14 @@ export class VAxios {
} }
resolve(res as unknown as Promise<T>); resolve(res as unknown as Promise<T>);
}) })
.catch((e: Error) => { .catch((e: Error | AxiosError) => {
if (requestCatchHook && isFunction(requestCatchHook)) { if (requestCatchHook && isFunction(requestCatchHook)) {
reject(requestCatchHook(e, opt)); reject(requestCatchHook(e, opt));
return; return;
} }
if (axios.isAxiosError(e)) {
// rewrite error message from axios in here
}
reject(e); reject(e);
}); });
}); });
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册