【发布时间】:2019-09-19 21:28:01
【问题描述】:
我正在尝试将服务内的查询参数传递给 REST API。
我应该如何传递给 API 的示例。(预期)
http://localhost:2000/world/123456789/avengers?type=fruits&fields=_all
试过如下:
all(countId) {
const headers: HttpHeaders = new HttpHeaders({
"_id" : countId,
"content-type" : "application/json"
});
let params = new HttpParams();
params = params.append("type", "fruits");
params = params.append("fields", "_all");
const options = {
headers: headers,
params: params
};
return this.http.put ( "http://localhost:2000/world/123456789/avengers", options )
}
但我无法传递它们有查询参数。我将如何做到这一点?
【问题讨论】:
标签: angular typescript api service query-parameters