2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-08 17:22:34 +03:00

Fixing #537 Rejecting promise if request is cancelled by the browser

This commit is contained in:
mattridley
2018-03-05 16:11:55 +00:00
parent d4dc124f15
commit 762044e453
6 changed files with 42 additions and 6 deletions
+12
View File
@@ -80,6 +80,18 @@ module.exports = function xhrAdapter(config) {
request = null;
};
// Handle browser request cancellation (as opposed to a manual cancellation)
request.onabort = function handleAbort() {
if (!request) {
return;
}
reject(createError('Request aborted', config, 'ECONNABORTED', request));
// Clean up request
request = null;
};
// Handle low level network errors
request.onerror = function handleError() {
// Real errors are hidden from us by the browser