From de1f30d605cede54afbb5e3903c1c15003e183c0 Mon Sep 17 00:00:00 2001 From: lf <1534621107@qq.com> Date: Mon, 17 Jun 2024 18:18:09 +0800 Subject: [PATCH] =?UTF-8?q?401=20=E9=80=80=E5=87=BA=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/http.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/utils/http.ts b/src/utils/http.ts index db65874..53cc733 100644 --- a/src/utils/http.ts +++ b/src/utils/http.ts @@ -13,12 +13,12 @@ export const http = (options: CustomRequestOptions) => { responseType: 'json', // #endif // 响应成功 - success(res) { + success(res: any) { // 状态码 2xx,参考 axios 的设计 - if (res.statusCode >= 200 && res.statusCode < 300) { + if (res.data?.code >= 200 && res.data?.code < 300) { // 2.1 提取核心数据 res.data resolve(res.data as IResData) - } else if (res.statusCode === 401) { + } else if (res.data?.code === 401) { // 401错误 -> 清理用户信息,跳转到登录页 window.parent.postMessage( {