If you are building an Angular 2 app, there will come a time when you need external data. The way to make this happen is through the HTTP service. HTTP allows you to make requests against remote endpoints and parse this data into a usable format.
The HTTP service has changed a lot since Angular 1. The main difference is the fact that information returned from HTTP is in the form of an
Observable. As a result, we need to use special operators to handle the response. Follow along in this Coffee Break Course as instructor Reggie Dawson shows you the ins and outs of HTTP with Angular 2.
1. How to Use the Angular 2 HTTP Service
In this coffee break course, we will look at how to use the HTTP service in Angular 2. One of the attractive things about Angular 2 is how it handles displaying data. For the most part, all you have to do is feed Angular 2 a raise and you will be able to display your data any way you like. Normally this data is coming from a remote source and this is where HTTP comes in. HTTP allows you to query remote end points and pull data into your app. For the most part, if you're familiar with Ajax, you'll be right at home using HTTP and Angular with one exception. The Angular team has chosen to use observable as the return data type of their HTTP service. Observables have to be handled with the RXDX operator to transform the data to a usable form. In this course we will go over how to create a service that uses HTTP to grab data. We won't use an actual remote data source but instead we will use an Angular 2 package that allows us to simulate connecting to remote endpoints. After we have the data, we will learn how the RXDX operators allow us to transform this data to a usable form. After that you should have a solid understanding on how to use a HTTP in your Angular 2 projects.