gpt4 book ai didi

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

转载 作者:太空狗 更新时间:2023-10-29 17:30:30 30 4
gpt4 key购买 nike

我已经将 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 6 或 7 : How to import RequestOptions and ResponseContentType in '@angular/common/http' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53118316/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com