angular6或7:如何在'@angular/common/http'中导入RequestOptions和ResponseContentType
angular 6 or 7: How to import RequestOptions and ResponseContentType in '@angular/common/http'
我已将 angular 4 代码迁移到 angular 6,我想知道如何在 angular 6 或 7 中导入以下代码?
import { RequestOptions, ResponseContentType } from '@angular/common/http';
从这边过去...
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)
)
);
我已将 angular 4 代码迁移到 angular 6,我想知道如何在 angular 6 或 7 中导入以下代码?
import { RequestOptions, ResponseContentType } from '@angular/common/http';
从这边过去...
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)
)
);