Intercepting Server Errors In Angular $http And Rejecting Promise
I'm using the Angular HTTP service and intercepting the response from the server to catch any server errors and do some stuff with them (logging etc.) before rejecting the promise.
Solution 1:
$q.reject(rejection);
returns a new rejected promise, it doesn't affect the state of existing promise. In fact, all that responseError
does here is catches the rejection and returns undefined
response instead.
It should be
responseError: function(rejection) {
doSomeStuff(rejection);
return $q.reject(rejection);
}
Post a Comment for "Intercepting Server Errors In Angular $http And Rejecting Promise"