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:
Julien Calixte
2026-06-01 21:47:19 +02:00
parent 39accae46e
commit 360244dc08
2 changed files with 8 additions and 6 deletions

View File

@@ -15,8 +15,6 @@ export default [
{ name: 'Swiss franc', code: 'CHF' },
{ name: 'Icelandic krona', code: 'ISK', symbol: 'kr' },
{ 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: 'Australian dollar', code: 'AUD', symbol: 'A$' },
{ name: 'Brazilian real', code: 'BRL', symbol: 'R$' },

View File

@@ -3,7 +3,7 @@ import couchService from '@/services/CouchService'
import formatDate from '@/utils/format-date'
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
@@ -42,12 +42,16 @@ class ExchangeService {
}
}
} else {
const url = new URL(
date ? `${this.baseUrl}${formattedDate}` : 'latest'
)
const url = new URL(`${this.baseUrl}${date ? formattedDate : 'latest'}`)
if (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())
if (response.ok) {
exchange = await response.json()