I am relatively new to angular so I am not sure if I am missing something here.
I have an Http Interceptor for adding JWT tokens to requests as well as handling responses from the server.
.factory('myHttpInterceptor', ['$q', '$location', '$window', function($q, $location, $window) {
return {
request: function(request) {
console.log('myHttpInterceptor - request');
return request;
},
requestError: function(requestError) {
console.log('myHttpInterceptor - requestError');
return requestError;
},
response: function(response) {
console.log('myHttpInterceptor - response');
return response;
},
responseError: function(responseError) {
console.log('myHttpInterceptor - responseError');
return responseError;
}
};
}]);
//Http Intercpetor to check auth failures
angular.module("POSMobile").config(['$httpProvider', function($httpProvider) {
$httpProvider.interceptors.push('myHttpInterceptor');
}]);
So here is the problem, I am trying to handle a 401 Unauthorized error by changing the route to my login screen however the responseError listener doesn't ever seem to fire.
I have checked my iis logs and my service is definitely returning a 401 code
Here I did a test using Postman and picked up the 401Screenshot of Postman
However in my interceptor it evaluates like so xdk debug screenshot
and finally after the request is completed I get a 401 error in the debug console
Thanks in advance