refactor(exchange): switch rates API to frankfurter.dev
Drop HRK and RUB from the currency list since frankfurter.dev no longer publishes them, and request only the rates we need via the symbols param.
This commit is contained in:
@@ -15,8 +15,6 @@ export default [
|
|||||||
{ name: 'Swiss franc', code: 'CHF' },
|
{ name: 'Swiss franc', code: 'CHF' },
|
||||||
{ name: 'Icelandic krona', code: 'ISK', symbol: 'kr' },
|
{ name: 'Icelandic krona', code: 'ISK', symbol: 'kr' },
|
||||||
{ name: 'Norwegian krone', code: 'NOK', symbol: 'øre' },
|
{ name: 'Norwegian krone', code: 'NOK', symbol: 'øre' },
|
||||||
{ name: 'Croatian kuna', code: 'HRK', symbol: 'kn' },
|
|
||||||
{ name: 'Russian rouble', code: 'RUB' },
|
|
||||||
{ name: 'Turkish lira', code: 'TRY' },
|
{ name: 'Turkish lira', code: 'TRY' },
|
||||||
{ name: 'Australian dollar', code: 'AUD', symbol: 'A$' },
|
{ name: 'Australian dollar', code: 'AUD', symbol: 'A$' },
|
||||||
{ name: 'Brazilian real', code: 'BRL', symbol: 'R$' },
|
{ name: 'Brazilian real', code: 'BRL', symbol: 'R$' },
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import couchService from '@/services/CouchService'
|
|||||||
import formatDate from '@/utils/format-date'
|
import formatDate from '@/utils/format-date'
|
||||||
|
|
||||||
class ExchangeService {
|
class ExchangeService {
|
||||||
private baseUrl: string = 'https://api.exchangeratesapi.io/'
|
private baseUrl: string = 'https://api.frankfurter.dev/v1/'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get an exchange with defined date and desired currencies
|
* Get an exchange with defined date and desired currencies
|
||||||
@@ -42,12 +42,16 @@ class ExchangeService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const url = new URL(
|
const url = new URL(`${this.baseUrl}${date ? formattedDate : 'latest'}`)
|
||||||
date ? `${this.baseUrl}${formattedDate}` : 'latest'
|
|
||||||
)
|
|
||||||
if (base) {
|
if (base) {
|
||||||
url.searchParams.append('base', base)
|
url.searchParams.append('base', base)
|
||||||
}
|
}
|
||||||
|
if (rates.length) {
|
||||||
|
url.searchParams.append(
|
||||||
|
'symbols',
|
||||||
|
rates.filter((r) => r !== base).join(',')
|
||||||
|
)
|
||||||
|
}
|
||||||
const response = await fetch(url.toString())
|
const response = await fetch(url.toString())
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
exchange = await response.json()
|
exchange = await response.json()
|
||||||
|
|||||||
Reference in New Issue
Block a user