Files
purple-explorer/lib/apis/coindesk.js
T
joeuhren 20c0a382a3 Code cleanup
-Replace tabs with double-spaces
-Betting spacing and lining up of code functions
-Add missing semi-colons
-Remove extra characters and spaces where applicable
-Remove commented-out code fragments
-Add missing 2021 date to LICENSE
-Small touchups and other misc nitpickings
2021-03-17 17:54:09 -06:00

23 lines
554 B
JavaScript

var request = require('postman-request');
function get_usd_value(cb) {
request({ uri: 'https://api.coindesk.com/v1/bpi/currentprice/USD.json', json: true, headers: {'User-Agent': 'eiquidus'} }, function (error, response, body) {
if (error)
return cb(error, 0);
else
return cb(null, body.bpi.USD['rate_float'].toFixed(4));
});
}
module.exports = {
get_data: function (cb) {
var error = null;
get_usd_value(function (err, last_usd) {
if (err)
error = err;
return cb(error, last_usd);
});
}
};