mirror of
https://github.com/tenrok/axios.git
synced 2026-06-23 20:40:40 +03:00
Fixed a regression bug with unsubscribing from cancel token; (#4819)
Reverts #4795; Co-authored-by: Jay <jasonsaayman@gmail.com>
This commit is contained in:
@@ -100,7 +100,6 @@ function setProxy(options, configProxy, location) {
|
|||||||
/*eslint consistent-return:0*/
|
/*eslint consistent-return:0*/
|
||||||
export default function httpAdapter(config) {
|
export default function httpAdapter(config) {
|
||||||
return new Promise(function dispatchHttpRequest(resolvePromise, rejectPromise) {
|
return new Promise(function dispatchHttpRequest(resolvePromise, rejectPromise) {
|
||||||
let onCanceled;
|
|
||||||
let data = config.data;
|
let data = config.data;
|
||||||
const responseType = config.responseType;
|
const responseType = config.responseType;
|
||||||
const responseEncoding = config.responseEncoding;
|
const responseEncoding = config.responseEncoding;
|
||||||
@@ -118,11 +117,11 @@ export default function httpAdapter(config) {
|
|||||||
isFinished = true;
|
isFinished = true;
|
||||||
|
|
||||||
if (config.cancelToken) {
|
if (config.cancelToken) {
|
||||||
config.cancelToken.unsubscribe(onCanceled);
|
config.cancelToken.unsubscribe(abort);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.signal) {
|
if (config.signal) {
|
||||||
config.signal.removeEventListener('abort', onCanceled);
|
config.signal.removeEventListener('abort', abort);
|
||||||
}
|
}
|
||||||
|
|
||||||
emitter.removeAllListeners();
|
emitter.removeAllListeners();
|
||||||
|
|||||||
+1
-6
@@ -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);
|
const protocol = parseProtocol(fullPath);
|
||||||
|
|
||||||
if (protocol && platform.protocols.indexOf(protocol) === -1) {
|
if (protocol && platform.protocols.indexOf(protocol) === -1) {
|
||||||
@@ -246,6 +241,6 @@ export default function xhrAdapter(config) {
|
|||||||
|
|
||||||
|
|
||||||
// Send the request
|
// Send the request
|
||||||
request.send(requestData);
|
request.send(requestData || null);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user