From the course: Building Angular and ASP.NET Web API Apps

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Handling errors in angular

Handling errors in angular

From the course: Building Angular and ASP.NET Web API Apps

Start my 1-month free trial

Handling errors in angular

- [Instructor] Now that we created our web API endpoint and we sent the request form our Angular application, let us see how we can handle the errors, in case something goes wrong with our web API endpoint, and then later, let us see how we can store the response in our local storage. We need to cache the errors as well, so for that we write comma, and then inside parentheses we write error. Then what we want to do with this error is that we just need to show this to the users, so for now we write alert and then error.error.Message. Let us run this application as well and see the result. So ng serve -o. Go to the login component, and here just enter a username and a password. So I will just type username which does not exist and the password which does not exist. And then click the login button. Here we get the response wrong credentials and on the console you are going to see that we are returning a bad request and this is the message that we are returning. Let us try to just leave…

Contents