web-dev-qa-db-fra.com

angular 6 ou 7: comment importer RequestOptions et ResponseContentType dans '@ angular/common/http'

J'ai migré le code angulaire 4 en angulaire 6. Comment importer le code ci-dessous en angulaire 6 ou 7 Import {RequestOptions, ResponseContentType} de '@ angular/common/http';

1
Amol B Lande

Passer par ici ... 

import { HttpClient, HttpHeaders } from '@angular/common/http';

 let headers = new HttpHeaders({
    'Content-Type': 'application/json'
 });
 let options = {
    headers: headers
 }

 this.http.post(URL, param, options)
    .subscribe(data => {
         console.log(data);
 });



 // For pass blob in API 

 return this.http.get(url, { headers: new HttpHeaders({
   'Authorization': '{data}',
   'Content-Type': 'application/json',
 }), responseType: 'blob'}).pipe (
 tap (
     // Log the result or error
     data => console.log('You received data'),
     error => console.log(error)
  )
);
4
Sachin Shah