...

/

HttpClient Service

HttpClient Service

In this lesson, we will briefly look at the use of HttpClient module in Angular to perform HTTP operations.

intro-httpclient

Angular provides a simplistic HTTP API for performing HTTP operations in angular applications. The front-end applications need to communicate with a server over the HTTP protocol to download data, upload data, and access other back-end services.

Features of HTTP

It offers features like:

  • Error handling
  • Request and response interception.
  • Typed response objects

Working with HTTP

To work with the HTTP protocol in Angular, we need to have the required imports from the HTTP packages.

import { HttpClientModule } from '@angular/common/http';

Add it to the imports array:

@NgModule({
  imports: [
    BrowserModule,
    HttpClientModule
  ],

We ...