2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-14 18:42:33 +03:00

Fixing reject not being called on xhr network errors.

Fixes #204
This commit is contained in:
Philip Roberts
2016-01-22 16:39:41 +00:00
parent a473744e05
commit 252876c2c0
2 changed files with 33 additions and 0 deletions
+10
View File
@@ -63,6 +63,16 @@ module.exports = function xhrAdapter(resolve, reject, config) {
request = null;
};
// Handle low level network errors
request.onerror = function handleError() {
// Real errors are hidden from us by the browser
// onerror should only fire if it's a network error
reject(new Error('Network Error'));
// Clean up request
request = null;
};
// Add xsrf header
// This is only done if running in a standard browser environment.
// Specifically not if we're in a web worker, or react-native.