I don't know what the right code is to get all the data of the API after response.data. I use the API by ethermine.
Here's my code:
global.etherminepool = `https://api.ethermine.org/poolStats`;
axios.get(etherminepool)
.then(function(response) {
// handle success
console.log(response.data); // I tried "response.data.price.eur". Do I have to use () or []?
})
.catch(function (error) {
// handle error
console.log(error);
})
.then(function () {
// always executed
});
When I tried response.data.price.eur the error is: TypeError: Cannot read property 'eur' of undefined. Also response.data.price didn't work.
The response of response.data is:
{
status: 'OK',
data: {
topMiners: [],
minedBlocks: [
[Object], [Object],
[Object], [Object],
[Object], [Object],
[Object], [Object],
[Object], [Object]
],
poolStats: {
hashRate: 180365172843161.53,
miners: 320965,
workers: 980198,
blocksPerHour: 68.92
},
price: {
time: '2021-10-10T10:09:56.000Z',
usd: 3580.5,
btc: 0.0650543794,
eur: 3094.580078125,
cny: 23070,
rub: 257127
},
estimates: {
time: '2021-10-10T10:09:56.000Z',
blockReward: 2.1481,
hashrate: 695958780441595,
blockTime: 13.5318,
gasPrice: 59.0492384812
}
}
}
As @J_K sayed the correct way was "response.data.data.price.eur"