I am using the cryptocompare npm package like this
const cc = require('cryptocompare');
cc.priceFull('ETH', 'USD')
.then(prices => {
console.log(prices);
}).catch(console.error)
which returns me this:
{
ETH: {
USD: {
TYPE: '5',
MARKET: 'CCCAGG',
FROMSYMBOL: 'ETH',
TOSYMBOL: 'USD',
FLAGS: '4',
PRICE: 1152.42,
LASTUPDATE: 1487865689,
LASTVOLUME: 0.21,
LASTVOLUMETO: 242.20349999999996,
LASTTRADEID: 1224703,
VOLUME24HOUR: 53435.45299122338,
VOLUME24HOURTO: 60671593.843186244,
OPEN24HOUR: 1119.31,
HIGH24HOUR: 1170,
LOW24HOUR: 1086.641,
LASTMARKET: 'itBit',
CHANGE24HOUR: 33.11000000000013,
CHANGEPCT24HOUR: 2.958072383879366,
SUPPLY: 16177825,
MKTCAP: 18643649086.5
}
}
}
How can I now get the specific value (2.958072383879366) for CHANGEPCT24HOUR
?
Tried a for-in
loop to iterate through each object but still struggling with it.
below may help
// let a='ETH', b= 'USD'
const cc = require('cryptocompare');
cc.priceFull(a, b)
.then(prices => {
console.log(prices[a][b].CHANGEPCT24HOUR);
}).catch(console.error)