AngularJS: Under what specific circumstances is a promise returned by $http rejected? -


i'm pretty new angular (or javascript in general) , have dumb question here. understand how promises work, under specific circumstances promise returned $http request (put or get or whatever) rejected? i'm pretty sure if request times out promise rejected; other errors 404 or 403? couldn't find such information angular docs... lot!

if somehow $http error occur, promise rejected. $httpprovider based on interceptor pattern, every request/response pass through pipeline handles error.

the default interceptor, built in angularjs this, reject promise:

'responseerror': function(rejection) {   // on error   if (canrecover(rejection)) {     return responseornewpromise   }   return $q.reject(rejection); //<------ rejecting promise here given http error } 

you can build , attach own interceptor inside $httpprovider handle specific errors (400, 500, etc). take @ interceptor section, under $http documentation.


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -