HTTP Requests
In this lesson, we'll learn how to make an HTTP request with Angular.
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 anywhere in our application after we’ve imported it.
In the app.module.ts
file, we’ll update the class file to use the HttpClientModule
.
Get hands-on with 1200+ tech skills courses.