From e52af17ee8d4e50a1e34b3148aaf8499a15df59c Mon Sep 17 00:00:00 2001 From: zhoulixiang <18366276315@163.com> Date: Wed, 4 May 2022 01:04:58 +0800 Subject: [PATCH] opt: opt judgment code of cancel (#4587) Co-authored-by: Jay --- lib/adapters/http.js | 2 +- lib/adapters/xhr.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/adapters/http.js b/lib/adapters/http.js index 04a9aac..3740bce 100755 --- a/lib/adapters/http.js +++ b/lib/adapters/http.js @@ -402,7 +402,7 @@ module.exports = function httpAdapter(config) { if (req.aborted) return; req.abort(); - reject(!cancel || (cancel && cancel.type) ? new CanceledError() : cancel); + reject(!cancel || cancel.type ? new CanceledError() : cancel); }; config.cancelToken && config.cancelToken.subscribe(onCanceled); diff --git a/lib/adapters/xhr.js b/lib/adapters/xhr.js index 534a0b9..16e6683 100644 --- a/lib/adapters/xhr.js +++ b/lib/adapters/xhr.js @@ -193,7 +193,7 @@ module.exports = function xhrAdapter(config) { if (!request) { return; } - reject(!cancel || (cancel && cancel.type) ? new CanceledError() : cancel); + reject(!cancel || cancel.type ? new CanceledError() : cancel); request.abort(); request = null; };