Angular 2: Http response status codes as constants

Does the Angular 2 framework support Http response status codes as constants ?

So instead of writing 404, I can write HttpStatus.NOT_FOUND .

Thanks!

+5
source share
1 answer

Unfortunately, at this point in time, there is no enumeration or constant for exact error codes.

You would be better off doing something like @Jeff, suggesting you use a library such as http-status-codes , which has all of these listed and documented.

Angular The response class allows you to check whether the request was successful using the "ok" (logical) property, otherwise you can access the status code / text from this object.

0
source

Source: https://habr.com/ru/post/1269748/


All Articles