I just built an interceptor Service in angularJS to catch all errors from API calls to handle general errors like so:
$provide.factory('myHttpInterceptor', function($q, dependency1, dependency2) {
return {
'responseError': function(rejection) {
alert("Something went wrong");
return $q.reject(rejection);
}
};
});
Works prefectly and my server sends back this on error with a status of 409
{
message: "Email is already being used"
success: false
token: ""
}
How can access this response from the responseError interceptor?