简体   繁体   中英

Only status 200 is good anything else is an error in angular $http?

Quick question:

Angular $http returns a promise. The promise can be a success, resolved object (status 200) or an error, reject object (status 404). Does that mean that anything that is not a status 200 response IN angular $http will be rejected and sent to the error part of the promise? Example: 404,304,401, 500, etc.

Anything that begins with a 2xx is a successful response:

https://en.wikipedia.org/wiki/List_of_HTTP_status_codes

Yes by default. However, you can change that behaviour using interceptors, where you can choose what kind of promise execution to return, and that will modify the pipe to be executed in the original call.

More info about interceptors

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM