2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-17 19:21:29 +03:00

Fixing issue with calling cancel after response has been received

This commit is contained in:
Nick Uraltsev
2016-10-17 18:20:13 -07:00
parent 3f8b128da4
commit 3fcf54ff36
3 changed files with 31 additions and 0 deletions
+4
View File
@@ -188,6 +188,10 @@ module.exports = function httpAdapter(config) {
if (config.cancelToken) {
// Handle cancellation
config.cancelToken.promise.then(function onCanceled(cancel) {
if (aborted) {
return;
}
req.abort();
reject(cancel);
aborted = true;
+4
View File
@@ -156,6 +156,10 @@ module.exports = function xhrAdapter(config) {
if (config.cancelToken) {
// Handle cancellation
config.cancelToken.promise.then(function onCanceled(cancel) {
if (!request) {
return;
}
request.abort();
reject(cancel);
// Clean up request