Does Angular 2 framework contain Http Response Status Codes as constants?
So instead of writing 404 I can write HttpStatus.NOT_FOUND.
Thanks!
Does Angular 2 framework contain Http Response Status Codes as constants?
So instead of writing 404 I can write HttpStatus.NOT_FOUND.
Thanks!
as of now in angular 12 this feature is now available
Unfortunately at this point in time there doesn't seem to be an enum or const for the exact error codes.
You'd be better off doing something like @Jeff suggested, by using a library like the http-status-codes which has them all listed and documented.
Angular's Response class allows you to check if a request was successful by means of the 'ok' property (boolean), otherwise you can access the status code/text from that object.