如何将 json 变量插入到 ionic 5 中的 httpClient 获取 url 参数

how to insert json variable to httpClient get url parametres in ionic 5

我正在使用 ionic 5,我想从客户端用户那里获取 ip 并将其放入 url get 我用它来获取 ip

this.ipclient = this.httpClient.get("https://api.ipify.org/?format=json");
this.ipclient
.subscribe(ipclient => {
console.log('my ip is: ', ipclient);
});

我想把结果放在另一个地方

this.offs = this.httpClient.get("https://example.com/?affiliateid=1507&ip=(i want put ip here)&device=android");
this.offs
.subscribe(offs => {
console.log('my result: ', offs);
});

如果可能的话,我需要帮助,谢谢

如果你想链接它们,你可以使用如下的switchMap

    this.httpClient.get("https://api.ipify.org/?format=json")
    .pipe(
      switchMap((ipclient: string) => this.httpClient.get(`https://example.com/?affiliateid=1507&ip=${ipclient}&device=android`))
    )
    .subscribe(offs => {
        console.log('my result: ', offs);
    })