HTTP Requests
Explore how to import and use Angular's HttpClientModule for making HTTP requests. Learn to create a search method in a service that queries an external API and retrieves data via observables. Understand how to subscribe to these observables in a component to handle asynchronous data.
We'll cover the following...
It’s time to make a request to the Cocktail DB API. If you’ve developed some applications previous to this course, you may already be familiar with how requests work. They can be made with the XMLHttpRequest object or the fetch API. There are also libraries, such as Axios, that simplify making a request.
Angular is a framework that comes with a solution baked in. It has an HTTP client we can use to perform requests. We won’t need to use 3rd party libraries to help us with this.
The HttpClientModule
By default, the HTTP client is not available in our project. We need to import a module that will expose the HTTP client to our application. We’ll be able to make requests ...