exchange rates towards USD
var rp = require("request-promise");
var jsonData = await rp("https://www.kimonolabs.com/download/6eg4dlkq?apikey=v3n5rBZStfZ0nAujuhRChstaiBkpEsaU&type=json&kimmodify=1");
var data = JSON.parse(jsonData);
var collection = data.results.collection1
collection.push({abbr: "MDL", code : "001", currency: "Moldavian Leu", index: "0", rate: "1", rates: "1", url: "https://www.bnm.md/en/content/official-exchange-rates"})
var _ = require("lodash");
var rates = module.exports.rates = function(){
var ratesInUSD = {};
var MDLUSD = 0;
_(collection).forEach(function(item){
if(item.abbr === "USD")
MDLUSD = item.rates;
});
_(collection).each(function(item){
ratesInUSD[item.abbr] = item.rates / item.rate / MDLUSD;
}).value();
return ratesInUSD
};
no comments