Simple API call to CoinMarketCap for the USD price of DIVI.
npm i --save request request-promise lodash
const rp = require('request-promise'); | |
const _ = require('lodash'); | |
let options = { | |
uri: 'https://api.coinmarketcap.com/v1/ticker/divi/', | |
qs: { | |
convert: 'USD' | |
}, | |
headers: { | |
'User-Agent': 'Request-Promise' | |
}, | |
json: true | |
}; | |
rp(options) | |
.then((response) => { | |
let usdPrice = _.round(response[0].price_usd, 3) | |
console.log(`USD price: ${usdPrice}`); | |
// Render the price however you see fit | |
}); |