feature/improved the getting of rates

This commit is contained in:
Joaquin committed 2025-05-06 21:26:45 -07:00
1 parent 93a5c45dd9
commit 17f11c85df
9 files changed
+44 -58

No files matched your search

+18
View File
@@ -0,0 +1,18 @@
const countries = require("./countries.json").countries;
async function getRates(country) {
let abbr;
countries.forEach(c => {
if (c.country === country) {
abbr = c.currency_abbreviation;
}
});
const res = await fetch(`https://api.frankfurter.dev/v1/latest?base=${abbr}`);
const data = await res.json();
let rates = data.rates;
return rates;
}
module.exports = getRates;