My question pertains to the interceptor(responseError) of $resource
. It is essential to note that I am working with angularjs version V1.3.6
.
The Issue:
app.factory('authInterceptor',['$q', '$location', '$log', function($q, $location, $log){
$log.debug('this is a standard factory with dependencies injection');
return {
responseError: function(response){
console.log(response)
// The issue lies in the inability to check for 401 using response.status,
// since the response received here is an ERROR OBJECT such as `SyntaxError: ...`. Is there any way to retrieve the status?
return $q.reject(response);
}
}
}])
When a 401 response is received, the arguments of responseError
hold an ERROR OBJECT like SyntaxError: Unexpected token U
because the server response is plain text Unauthorized
with a status code of 401
.
However, my intention is to access the response.status
and perform a specific action if it is 401
.
Any assistance on this matter would be greatly appreciated.