Search code examples
angulartypescriptangular-httpclient

How to replace a token in the URL when calling HttpClient.get()


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


Solution

  • Use backticks `` instead of simple quotes '