I'm using an API to get balance in a bitcoin address.
My code is:
async function getWalletBalance(address) {
try {
const response = await got(`blockchain.info/balance?active=${address}`)
return response.body.address.final_balance
} catch(err) {
return err
}
}
The returning JSON is:
{
"3D2oetdNuZUqQHPJmcMDDHYoqkyNVsFk9r": {
"final_balance": 15392048444281,
"n_tx": 3938,
"total_received": 138450271881712
}
}
But when I try to read the final balance, it gives me undefined. How do I fix this?