mirror of
https://github.com/tenrok/axios.git
synced 2026-06-02 16:04:10 +03:00
Merge pull request #227 from rogeriochaves/master
Handle timeout on XHR requests
This commit is contained in:
@@ -76,6 +76,17 @@ module.exports = function xhrAdapter(resolve, reject, config) {
|
||||
request = null;
|
||||
};
|
||||
|
||||
// Handle timeout
|
||||
request.ontimeout = function handleTimeout() {
|
||||
var err = new Error('timeout of ' + config.timeout + 'ms exceeded');
|
||||
err.timeout = config.timeout;
|
||||
err.code = 'ECONNABORTED';
|
||||
reject(err);
|
||||
|
||||
// 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.
|
||||
|
||||
Reference in New Issue
Block a user