[英]Angular 9 http.Get request with paramaters
I am trying to send query parameters with a get request.我正在尝试使用获取请求发送查询参数。 This code always has an empty query {}.
此代码始终有一个空查询 {}。 What am I missing?
我错过了什么?
let p = new HttpParams().set('Test', "7878");
return this.http
.get<Response>(environment.baseAPIUrl + route,
{
withCredentials: false,
headers: requestHeaders,
params: p,
responseType,
observe: observe as 'body'
}
);
Basically your use of HttpParams
seems okay and it's working for me.基本上你对
HttpParams
的使用似乎没问题,它对我有用。
Open my Stackblitz Example :打开我的Stackblitz 示例:
just note, that the error-message (1) will not include the url-parameters请注意,错误消息 (1) 将不包括 url 参数
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.