加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

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

发布时间:2020-12-17 07:35:48 所属栏目:安全 来源:网络整理
导读:我想用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=an
我想用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.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读