英文:
How to replace a token in the URL when calling HttpClient.get()
问题
使用httpClient.get()调用时,如何替换URL中的${fooId}标记:
this.httpClient.get('http://my-server/foo/${fooId}');
实际上,我正在使用以下方式进行替换:this.httpClient.get('http://my-server/foo/${fooId}'.replace('${fooId}', fooId)); 但我认为这不太干净。
英文:
How to replace ${fooId} token in the URL when calling httpClient.get() this way :
this.httpClient.get('http://my-server/foo/${fooId}');
Actually I'm using this.httpClient.get('http://my-server/foo/${fooId}'.replace('${fooId}', fooId)); but I think it's not very clean
答案1
得分: 4
Use backticks `` instead of simple quotes '.
英文:
Use backticks `` instead of simple quotes '
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论