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:
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user