I'm working on offline handling for a angularjs app with cordova (Android & iOS). I wrote an http interceptor, that checks for the status of an http requests, and decides what to do.
I had a working version some month ago, and suddenly this stopped working. I found out that I was checking for a http status of 0. Now this returns -1, but I don't why.
responseError: function(response) {
console.log(response.status); // this returns now -1
}
So my questions are:
- What are the standard http codes for ajax requests that define cases like network unavailable, offline, timeout... everything when the server is not reachable (e.g. when you shut down your server in development, your mobile connection breaks, or is too slow and times out...)
- Is the status code set by the browser, or manipulated by AngularJS?
- Are this codes the same across every browser? Desktop & mobile?
- What is the difference between code
0and-1?
There was a change in the more recent versions of angular, with the handling of http status code 0. Here is a github discussion based on the change.
I hope you have already solved you problem by now!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With