Chapter 9. Making HTTP Calls in Angular
In the previous chapter, we started our groundwork on Angular services. In particular, we took a look at what Angular services are and when to use them. We then dealt with creating Angular services and using them in our application, followed by a very cursory glance at dealing with asynchronous behavior in Angular using observables.
In this chapter, we will build on that base and start using the built-in Angular modules and services to make and parse HTTP calls to a server. We will use that to explore common paradigms, the API options, and how to chain and really use the power of observables in our application.
In this section, we will start using Angular’s
HttpClient to make GET and POST calls to a server. Through this, we will see how to set up our application so that we can make the calls, walk through the process of actually making the calls and dealing with the response, and then go into the API signature and all the various options that we have to tweak it to our needs.
As for the server, we won’t be spending any time building it out, but rather using a prebuilt server for this application. It is a Node.js server, and available in the repository in case you are interested in digging deeper into it, but it is not required to understand this part of the book.
HttpClient Versus Http
If you happened upon some older tutorials and examples, you might encounter a slightly different way of making HTTP calls, by directly ...