diff options
| author | Adam Soltys <[email protected]> | 2023-12-05 08:23:34 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2023-12-05 08:23:38 -0800 |
| commit | a2f5a82deb28b383fab236bc61ed85cff7375311 (patch) | |
| tree | 7a5c62bbda8d88fba2760e801ddabefb919f09b9 /lib | |
| parent | e98ca84881152632a2e06e4376408c204644f3ad (diff) | |
| download | coinos-server-a2f5a82deb28b383fab236bc61ed85cff7375311.tar.gz coinos-server-a2f5a82deb28b383fab236bc61ed85cff7375311.zip | |
get rates from fixer
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/rates.js | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/rates.js b/lib/rates.js index a392c913..d1cbb92b 100644 --- a/lib/rates.js +++ b/lib/rates.js @@ -49,9 +49,15 @@ export let getRates = async () => { date = Date.now(); try { let r = await got( - `https://v6.exchangerate-api.com/v6/${config.exchange}/latest/USD` + `http://data.fixer.io/api/latest?access_key=${config.fixer}` ).json(); - let { conversion_rates: fx } = r; + let { rates: fx } = r; + let USD = fx['USD']; + + Object.keys(fx).map(k => { + fx[k] = fx[k] / USD; + }); + await s("rates", { date, fx }); } catch (e) { err("error fetching rates", e.message); |
