From fe5946daba510da24d518e288a4ba3b4e44fca84 Mon Sep 17 00:00:00 2001 From: winixt Date: Thu, 14 Dec 2023 19:32:15 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20skipErrorHandler=20=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/fes-plugin-request/package.json | 2 +- packages/fes-plugin-request/src/template/request.js | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/fes-plugin-request/package.json b/packages/fes-plugin-request/package.json index 08014f5c..731e3de7 100644 --- a/packages/fes-plugin-request/package.json +++ b/packages/fes-plugin-request/package.json @@ -1,6 +1,6 @@ { "name": "@fesjs/plugin-request", - "version": "3.0.3", + "version": "3.0.4", "description": "@fesjs/plugin-request", "main": "lib/index.js", "files": [ diff --git a/packages/fes-plugin-request/src/template/request.js b/packages/fes-plugin-request/src/template/request.js index 5a57a093..327a06ff 100644 --- a/packages/fes-plugin-request/src/template/request.js +++ b/packages/fes-plugin-request/src/template/request.js @@ -122,7 +122,10 @@ export const request = (url, data, options = {}) => { return currentRequestInstance.request(context).then(async () => { if (context.config.skipErrorHandler) { console.warn('3.x 已移除 skipErrorHandler 参数,请改用 dataHandler 处理'); - if (context.config.skipErrorHandler === true || context.response?.data?.code === context.config.skipErrorHandler) { + if ( + ((context.error || context.response?.data?.code !== '0') && context.config.skipErrorHandler === true) || + context.response?.data?.code === context.config.skipErrorHandler + ) { return Promise.reject(context.response); } }