angular 6 or 7: How to import RequestOptions and ResponseContentType in '@angular/common/http'

后端 未结 1 1546
青春惊慌失措
青春惊慌失措 2020-12-31 19:07

I have migrated angular 4 code to angular 6 and I want to know how to import below code in angular 6 or 7?

import { RequestOptions, ResponseContentType } fro         


        
相关标签:
1条回答
  • 2020-12-31 19:16

    Pass this way ...

    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)
      )
    );
    
    0 讨论(0)
提交回复
热议问题