DS_*_*per 25 httpclient angular
所以,我正试图从'旧'http迁移到新的httpClient
使用http客户端我在我的服务中使用这种格式:
return this.http.get(environment.api+ '.feed.json', requestOptions)
Run Code Online (Sandbox Code Playgroud)
我如何在httpClient中使用它?
尝试了许多thiungs ...包括
return this.http.get(environment.api+ '.feed.json', {params: requestOptions.params})
Run Code Online (Sandbox Code Playgroud)
但得到一个类型错配:(
And*_*aru 22
试试这个:
const requestOptions = {
params: new HttpParams()
};
requestOptions.params.set('foo', 'bar');
this.http.get(environment.api+ '.feed.json', requestOptions );
Run Code Online (Sandbox Code Playgroud)
这里也是文档的链接,描述了如何使用标题和URL参数的示例:HttpClient
| 归档时间: |
|
| 查看次数: |
31189 次 |
| 最近记录: |