微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

使用方法GET的Angular HttpClient参数不起作用

我想用get方法向你询问params.
我有这样的事:
path = 'https://example.com/api';
    const params = new HttpParams();
    params.append('http','angular');
    return this.http.get(path,{params: params});

我以为我会像以下网址:

www.example.com/api?http=angular

但实际上当我在chrome中的网络选项卡中检查时,请求url是

www.example.com/api

当我想要路径时,我该怎么办:www.example.com/api?http=angular
是否可以检查没有铬的使用方法的请求URL?我的意思是在使用该方法的服务中?

提前致谢

您需要在追加函数调用后重新分配.它返回一个新的 HttpParams对象.
const params = new HttpParams().append('http','angular');

这是the documentation of append.您可以看到它返回HttpParams实例

append(param: string,value: string): HttpParams

Construct a new body with an appended value for the given parameter name.

And is it possible to check request url of used method without chrome ?

您可以创建一个HttpInterceptor并查看将在拦截函数实现中使用的整个URL.

原文地址:https://www.jb51.cc/angularjs/142498.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐