I just started learning programming and I'm currently working on creating an API call to use in another function. However, I've hit a roadblock. I need to extract values for variables a and b separately from the response of this API call:
import axios from "axios";
async function main() {
await axios
.get('https://api.blocknative.com/gasprices/blockprices?confidenceLevels=99', {
headers: {
Authorization: 'key'
},
})
.then(function(response) {
const a = response.data.blockPrices[0].estimatedPrices[0].maxFeePerGas;
const b = response.data.blockPrices[0].estimatedPrices[0].maxPriorityFeePerGas;
return [a, b]
});
};
main().catch(console.error);
Can anyone guide me on how to achieve this? I've looked into topics like scope, block, and destructuring but I'm still unable to find a solution. Thank you for your assistance!