Skip to content

Instantly share code, notes, and snippets.

@magemore
Created February 15, 2023 16:36
Show Gist options
  • Save magemore/d19372c388e05eac293ee0e59433cc98 to your computer and use it in GitHub Desktop.
Save magemore/d19372c388e05eac293ee0e59433cc98 to your computer and use it in GitHub Desktop.
//Using Axios
const axios = require('axios');
axios.get('https://pro-api.coinmarketcap.com/v1/tools/price-conversion?amount=1&symbol=MAIN&convert=USD', {
headers: {
'X-CMC_PRO_API_KEY': CMC_PRO_API_KEY,
},
})
.then(function (response) {
// get BNB price in BUSD
console.log(response.data.data.quote.USD.price);
// const bnbInBusd = response.data.data.quotes.BUSD.price;
// console.log(bnbInBusd);
})
.catch(function (error) {
// handle error
console.log(error);
})
.finally(function () {
// always executed
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment