From ad9a8bfd7c8589633a021c8950c676e27735da6a Mon Sep 17 00:00:00 2001 From: Jealous Date: Fri, 10 Jan 2025 20:44:29 +0800 Subject: [PATCH] fix(request): TypeError: Cannot read properties of undefined (reading 'status') (#225) --- src/hooks/usePath.ts | 4 +++- src/utils/request.ts | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/hooks/usePath.ts b/src/hooks/usePath.ts index da4fe163f9..0d0a276738 100644 --- a/src/hooks/usePath.ts +++ b/src/hooks/usePath.ts @@ -222,7 +222,9 @@ export const usePath = () => { to(pathname().replace(me().base_path, "")) return } - ObjStore.setErr(msg) + if (code === undefined || code >= 0) { + ObjStore.setErr(msg) + } } } const pageChange = (index?: number, size?: number, append = false) => { diff --git a/src/utils/request.ts b/src/utils/request.ts index 840bd40abd..3cfd47b7f0 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -46,7 +46,7 @@ instance.interceptors.response.use( // description: error.message, // }); return { - code: error.response.status, + code: axios.isCancel(error) ? -1 : error.response?.status, message: error.message, } },