Trying to get data.rate
value from data that looks like this:
{
"timestamp": "2016-10-16T15:00:07Z",
"error": "",
"data": [{
"pair": "EUR_USD",
"rate": "1.09727328"
}]
}
Console logging:
[{
name: 'Bitfinex',
rate: undefined
},
{
name: 'Bitstamp',
rate: undefined
},
{
name: 'Gdax',
rate: undefined
}
]
I have also tried bracket notation rateResponse.data['rate']
.
Full code:
Promise.all(cryptoxArray.map(cryptox =>
new Promise((resolve, reject) =>
cryptox.getRate({
pair: "XBT_USD"
}, (err, rateResponse) =>
err ? reject(err) : resolve({
name: cryptox.properties.name,
rate: rateResponse.data.rate
})
)
)
))
.then(rates => console.log(rates));
via chuckieDub
No comments:
Post a Comment