Skip to content

Commit c424d92

Browse files
committed
always update all supported currencies from exchangeratesapi
1 parent 14d1f6f commit c424d92

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/services/providers/exchangeRates.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ export async function updateExchangeratesapi(
2929
): Promise<FiatExchangeRates> {
3030
if (!options.exchangeratesapiKey) throw new WERR_MISSING_PARAMETER('options.exchangeratesapiKey')
3131

32-
const unique = Array.from(new Set([...targetCurrencies, 'USD']))
32+
// Always update all rates in one request.
33+
const unique = Array.from(new Set([...targetCurrencies, 'USD', 'EUR', 'GBP']))
3334
const iorates = await getExchangeRatesIo(options.exchangeratesapiKey, unique)
3435

3536
if (!iorates.success) throw new WERR_BAD_REQUEST(`getExchangeRatesIo returned success ${iorates.success}`)
@@ -46,7 +47,7 @@ export async function updateExchangeratesapi(
4647
rates: {}
4748
}
4849

49-
for (const currency of targetCurrencies) {
50+
for (const currency of unique) {
5051
if (currency === 'USD') {
5152
r.rates.USD = 1
5253
continue

0 commit comments

Comments
 (0)