mirror of
https://github.com/silkimen/cordova-plugin-advanced-http.git
synced 2026-04-24 00:00:03 +08:00
feat #283: improve error message on timeout on browser platform
This commit is contained in:
Vendored
+10
-1
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user