Created
February 15, 2023 16:36
-
-
Save magemore/d19372c388e05eac293ee0e59433cc98 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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