From 379fdebc46ede21815b7067830916eb612839e5e Mon Sep 17 00:00:00 2001 From: Dmitriy Mozgovoy Date: Wed, 14 Sep 2022 22:24:22 +0300 Subject: [PATCH] Fixed a regression bug with unsubscribing from cancel token; (#4819) Reverts #4795; Co-authored-by: Jay --- lib/adapters/http.js | 5 ++--- lib/adapters/xhr.js | 7 +------ 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/lib/adapters/http.js b/lib/adapters/http.js index 98effa1863..b31fbc8266 100755 --- a/lib/adapters/http.js +++ b/lib/adapters/http.js @@ -100,7 +100,6 @@ function setProxy(options, configProxy, location) { /*eslint consistent-return:0*/ export default function httpAdapter(config) { return new Promise(function dispatchHttpRequest(resolvePromise, rejectPromise) { - let onCanceled; let data = config.data; const responseType = config.responseType; const responseEncoding = config.responseEncoding; @@ -118,11 +117,11 @@ export default function httpAdapter(config) { isFinished = true; if (config.cancelToken) { - config.cancelToken.unsubscribe(onCanceled); + config.cancelToken.unsubscribe(abort); } if (config.signal) { - config.signal.removeEventListener('abort', onCanceled); + config.signal.removeEventListener('abort', abort); } emitter.removeAllListeners(); diff --git a/lib/adapters/xhr.js b/lib/adapters/xhr.js index 2f22f328d2..e0233f5e01 100644 --- a/lib/adapters/xhr.js +++ b/lib/adapters/xhr.js @@ -232,11 +232,6 @@ export default function xhrAdapter(config) { } } - // false, 0 (zero number), and '' (empty string) are valid JSON values - if (!requestData && requestData !== false && requestData !== 0 && requestData !== '') { - requestData = null; - } - const protocol = parseProtocol(fullPath); if (protocol && platform.protocols.indexOf(protocol) === -1) { @@ -246,6 +241,6 @@ export default function xhrAdapter(config) { // Send the request - request.send(requestData); + request.send(requestData || null); }); }