In this video, learn how to add code to handle HTTP errors that come back through the HttpClient service method calls.
- [Narrator] It's possible that … http calls may result in an error, … from a service that is temporarily down, … to a malformed request, response, … or even an error code in the response payload. … Let's take a look at some code that we can add … to handle errors that come through … the calls we make with the http client service. … In the "media-item.service.ts" file, … this code contains calls to the http service … get, post, and delete methods. … These return an observable, … and in the case of the get call, … we have the use of the pipe method … to apply an rxjs operator named a map … for extracting the media items … from the response payload. … The rxjs library provides an operator named "catchError" … that can be used to identify when … the observable emits an error, … and if so, allows you to run a function … to take some sort of action. … We can make use of the "catchError" rxjs operator here … by adding catch error to the import statement, … or "rxjs/operators". … And then down in the pipe method from the http get call, …
- What is Angular?
- Working with components
- Binding events and properties
- Getting data to components
- Using directives and pipes
- Creating Angular forms
- Validating form data
- How Angular does dependency injection
- Making HTTP calls
- Styling components
Skill Level Intermediate
Angular: Building an Interfacewith Ray Villalobos2h 20m Intermediate
1. Architecture Overview
3. Directives and Pipes
5. Dependency Injection and Services
8. Styling Components
Next steps1m 20s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.