I recently developed an interceptor Service using angularJS to capture any errors from API calls and manage general error handling like this:
$provide.factory('myHttpInterceptor', function($q, dependency1, dependency2) {
return {
'responseError': function(rejection) {
alert("An issue occurred");
return $q.reject(rejection);
}
};
});
It works perfectly, and my server returns the following response on error with a status of 409
:
{
message: "Email is already in use",
success: false,
token: ""
}
How can I access this response within the responseError
interceptor?