I have a trouble. I want to read crypto prices data. I make to this function.
function getCryptoPrice(ticker) {
var ticker = ticker || "ETH";
ticker = encodeURI(ticker);
var url=("https://pro-api.coinmarketcap.com/v1/cryptocurrency/quotes/latest?symbol=" ticker);
var requestOptions = {
method: 'GET',
uri: 'https://pro-api.coinmarketcap.com/.../cry.../listings/latest',
qs: {
start: 1,
limit: 5000,
convert: 'USD'
},
headers: {
'X-CMC_PRO_API_KEY': 'api'
},
json: true,
gzip: true
};
var httpRequest= UrlFetchApp.fetch(url, requestOptions);
var getContext= httpRequest.getContentText();
var parseData=JSON.parse(getContext);
return parseFloat(parseData.data.quote.USD.price)
}
When i debug the function result in picture enter image description here
when result is google sheet is second picture enter image description here Please, help me. i donť now where have mistake.
I expect function without mistake.
CodePudding user response:
Shouldn't it be?
parseData.data.ETH.quote.USD.price
Or
parseData.data[ticker].quote.USD.price