diff --git a/src/public/scripts/exchangeRate.js b/src/public/scripts/exchangeRate.js index 61cad77..8d6e08f 100644 --- a/src/public/scripts/exchangeRate.js +++ b/src/public/scripts/exchangeRate.js @@ -1,7 +1,6 @@ -function convert(from) { - fetch(`https://api.frankfurter.dev/v1/latest?base=${from}`) - .then((resp) => resp.json()) - .then((data) => { - console.log(data); - }); +async function convert(from) { + const res = await fetch(`https://api.frankfurter.dev/v1/latest?base=${from}`); + const data = await res.json(); + + return data; } \ No newline at end of file diff --git a/src/util/currencies.js b/src/util/currencies.js index 0519ecb..712720d 100644 --- a/src/util/currencies.js +++ b/src/util/currencies.js @@ -1 +1,6 @@ - \ No newline at end of file +const { getCollection } = require('./src/database/connection'); + +async function saveExchangeRates() { + const { currencies } = getCollection(); + await currencies.insertMany(convert()); +}