mirror of
https://github.com/silkimen/cordova-plugin-advanced-http.git
synced 2024-10-06 17:22:12 +08:00
feat #283: improve error message on timeout on browser platform
This commit is contained in:
parent
662b4352f5
commit
7193b636f1
@ -4,6 +4,7 @@
|
||||
|
||||
- Feature #291: add support for sending 'raw' requests (thanks to jachstet-sea and chuchuva)
|
||||
- Feature #155: add OPTIONS method
|
||||
- Feature #283: improve error message on timeout on browser platform
|
||||
|
||||
## 2.3.1
|
||||
|
||||
|
11
src/browser/cordova-http-plugin.js
vendored
11
src/browser/cordova-http-plugin.js
vendored
@ -171,10 +171,19 @@ function sendRequest(method, withData, opts, success, failure) {
|
||||
xhr.responseType = responseType;
|
||||
setHeaders(xhr, headers);
|
||||
|
||||
xhr.onerror = xhr.ontimeout = function () {
|
||||
xhr.onerror = function () {
|
||||
return failure(createXhrFailureObject(xhr));
|
||||
};
|
||||
|
||||
xhr.ontimeout = function () {
|
||||
return failure({
|
||||
status: -4,
|
||||
error: 'Request timed out',
|
||||
url: url,
|
||||
headers: {}
|
||||
});
|
||||
};
|
||||
|
||||
xhr.onload = function () {
|
||||
if (xhr.readyState !== xhr.DONE) return;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user