From 72634ffe6e6649d36ee41f7633c8ee2ab80cf25e Mon Sep 17 00:00:00 2001 From: CXM <16154023+littlecxm@users.noreply.github.com> Date: Mon, 16 Aug 2021 23:14:40 +0800 Subject: [PATCH] fix: add axios error info from response (#1083) * fix(type): fix ant-design-vue -> * fix: add axios error info from response --- src/utils/http/axios/Axios.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/utils/http/axios/Axios.ts b/src/utils/http/axios/Axios.ts index f7882a74..086adb1e 100644 --- a/src/utils/http/axios/Axios.ts +++ b/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); }) - .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); }); }); -- GitLab