I have a service that I get an http from API
export class DataDisplayFromAPI {
result:any;
constructor(private _http: HttpClient) {}
getPrices() {
return this._http.get("https://min-api.cryptocompare.com/data/pricemulti?fsyms=BTC,ETH,LTC,BCH,IOT,XRP&tsyms=USD")
.map(result => this.result = result);
}
}
What I try to do is to replace the coins list BTC,ETH,LTC,BCH,IOT,XRP inside the string with a variable, as follow:
export class DataDisplayFromAPI {
result:any;
coinsList = 'BTC,ETH,LTC,BCH,IOT,XRP';
constructor(private _http: HttpClient) {}
getPrices() {
return this._http.get("https://min-api.cryptocompare.com/data/pricemulti?fsyms=" + coinsList + "&tsyms=USD")
.map(result => this.result = result);
}
}
But get error.
I tried also
return this._http.get(`https://min-api.cryptocompare.com/data/pricemulti?fsyms=${coinsList}&tsyms=USD`)
But it also doesn't work
How can I do it?
Thanks