I'm wondering if there is a way in Google script to use a variable to get data and write it on a cell from a nested API call. For example:
var symbol = "BTC";
var responseAPI = UrlFetchApp.fetch(url+apikey+"&symbol="+symbol+"&convert=EUR");
var parcedData = JSON.parse(responseAPI.getContentText());
index.getRange(2,1).setValue([parcedData.data.BTC.symbol]);
index.getRange(2,2).setValue([parcedData.data.BTC.quote.EUR.price]);
This is the code I use to retrieve BTC price from new Coinmarketcap API (documentation is here https://coinmarketcap.com/api/documentation/v1/#operation/getV1CryptocurrencyQuotesLatest). Since I already declare the BTC symbol in a variable, is there a way to substitute BTC in "setValue"? Something like:
index.getRange(2,1).setValue([parcedData.data.+symbol+.symbol]);
variable here ^^^^^^
This is not working of course, is there a way to make it works? Thank you in advance