web-dev-qa-db-ja.com

angular 6または7: '@ angular / common / http'にRequestOptionsおよびResponseContentTypeをインポートする方法

angular 4 codeをangular 6に移行しました。以下のコードをangular 6または7?

import { RequestOptions, ResponseContentType } from '@angular/common/http';
6
Amol B Lande

このように渡します...

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)
  )
);
16
Sachin Shah