I'm trying to determine the network connectivity status (online/offline) following an unsuccessful request using the $http service in AngularJs. Despite examining all response parameters in the error handler, I couldn't find any information that could assist me.
Your assistance is greatly appreciated, Olivier
Here is the code snippet for the request:
$http({ method: method, url: url, data: data, headers: headers })
.success(function (result) {
deferred.resolve(result);
})
.error(function (data, status, headers, config, statusText) {
console.log(data);
console.log(status);
console.log(headers);
console.log(config);
console.log(statusText);
deferred.reject();
});
The following details are displayed in the console:
GET http://192.168.0.12:3000/test net::ERR_INTERNET_DISCONNECTED ionic.bundle.js:16185
backEnd.js:25
0 backEnd.js:26
function (name) {
if (!headersObj) headersObj = parseHeaders(headers);
if (name) {
return headersObj[lowercase(name)] || null;
}
return headersObj;
} backEnd.js:27
Object {method: "GET", transformRequest: Array[1], transformResponse: Array[1], url: "http://192.168.0.12:3000/test", data: null…} backEnd.js:28
undefined backEnd.js:29