I'd like to be able to handle the 401 status code in my angularjs project. I've attempted several different variations of response interceptors, but all of them return a code of -1. I'd like to understand why this is happening. Using Angularjs v1.5.8.
myApp.factory('httpResponseInterceptor', function () {
return {
responseError: function (config) {
console.log(config.status);
//The above prints out -1 to the console
return config;
}
};
});
myApp.config(function ($httpProvider) {
$httpProvider.interceptors.push('httpResponseInterceptor');
});