Introducing the Angular HTTP client
The built-in HTTP client of the Angular framework is a separate Angular library that resides in the @angular/common
npm package under the http
namespace. The Angular CLI installs this package by default when creating a new Angular project. To start using it, we need to import HttpClientModule
in the main application module app.module.ts
:
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { HttpClientModule } from '@angular/common/http';
import { AppComponent } from './app.component';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
HttpClientModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
The HttpClientModule
class provides various Angular services we can use to handle asynchronous HTTP communication. The most basic is the...