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/public/scripts/geolocation.js b/src/public/scripts/geolocation.js index 74e5652..e5c55b8 100644 --- a/src/public/scripts/geolocation.js +++ b/src/public/scripts/geolocation.js @@ -40,4 +40,4 @@ function error(err) { console.error("Geolocation error: ", err); } -getLocation(); \ No newline at end of file +//getLocation(); \ No newline at end of file diff --git a/src/util/currencies.js b/src/util/currencies.js index e69de29..8eb4ec3 100644 --- a/src/util/currencies.js +++ b/src/util/currencies.js @@ -0,0 +1,6 @@ +const { getCollection } = require('./src/database/connection'); + +async function saveExchangeRates() { + const { currencies } = getCollection(); + await currencies.insertMany(convert()); +} \ No newline at end of file