HTTP requests are discussed and demonstrated in a few steps. We import necessary interfaces required and add a constructor. We then remove hard-coded data and update our getMovie method so it does the following: return an observable of movies and use the MAP operator to map the response to a movie array using response.json.
- [Voiceover] So we're ready to send our first HTTP request.…So the first thing that we're going…to want to do to get that going…is to import HTTP response…is to import HTTP response…and the obervables that we'll need.…So let's go ahead and add those import statements…and movie.service.ts.…and movie.service.ts.…Next is to add a constructor to create an instance…of the movie service and a private variable…so the constructor can go right…in the beginning of the class…and our private variable can go right above it.…
So what we're doing with this private variable…is just IDing the location of our web server.…And we'll use a JSon file that we've been referencing…for simplicity.…And that JSon file is in the API folder…under movies, under movies.JSon.…Next we can finally get rid…of this hard coded data that we have here.…And get movies so let's go ahead and highlight this.…And get movies so let's go ahead and highlight this.…I'm gonna get rid of it…and basically just replace it with…this code here for get movies.…
Also I'm going to add some error handling…
- Creating components
- Bootstrapping components
- Working with templates
- Using directives and interpolation
- Binding and transforming data
- Creating advanced and nested components
- Creating services
- Obtaining data with HTTP calls
- Configuring routes
Skill Level Intermediate
1. Course Overview
3. Directives, Interpolation, and Templates
5. Advanced Components
7. Obtaining Data with HTTP
- 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.