python ruby-programming-language Smalltalk Vue.js Knockoutjs TypeScript JavaScript, OOPs JavaScript Angular 8,7,6,5,4 and 2 Interview Questions and Answers Angular 8,7,6,5,4 and 2 Interview Questions and Answers Angular 4 Angular 2 AngularJs 1.x NodeJs Perl Programming R Programming RequireJs Rust Programming Backbonejs closure programming language go-programming-language kotlin-programming-language
@angular/common/http

What’s the difference between HTTP and HttpClient?

Angular HTTP vs. HttpClient -
The HttpClient is used to perform HTTP requests and it imported form @angular/common/http.
The HttpClient is more modern and easy to use the alternative of HTTP.

HttpClient is an improved replacement for Http. They expect to deprecate Http in Angular 5 and remove it in a later version.

It's an upgraded version of http from @angular/http module with the following improvements –
1.      Immutable request and response objects
2.      Interceptors allow middleware logic to be inserted into the pipeline
3.      Progress events for both request and response
4.      Typed
5.      Event firing
6.      Synchronous response body access
7.      Support JSON body types and JSON by default and now, no need to be explicitly parsed
8.      Automatic conversion from JSON to an object
9.      Post request verification
10.  A flush based testing framework
11.  Simplified syntax for headers

The example with HttpClient -
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';

@Injectable()
export class CustomerService {
 
  //Inject HttpClient into your components or services
  constructor(private http: HttpClient) { }
}

And other example with Http –
import { Injectable } from '@angular/core';
import { Http } from '@angular/http';

@Injectable()
export class CustomerService {
 
  //Inject HttpClient into your components or services
  constructor(private http: Http) { }
}


For more detail kindly refer the link.... 
ANIL SINGH

Hi there! Welcome to my blog. My name is Anil Singh. I'm a author of this blog. For more detail about me, kindly refer to this link..
My Blogs - http://code-sample.com and http://code-sample.xyz
My Books - Interview Questions and Answers Books- Get Your Book in 15+ Digital Stores Worldwide..

You Might Also Like
www.code-sample.com/. Powered by Blogger.
ASK Questions