MCPcopy Create free account
hub / github.com/massCodeIO/massCode / fetchFiatRates

Function fetchFiatRates

src/main/currencyRates.ts:63–77  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

61}
62
63async function fetchFiatRates(): Promise<Record<string, number>> {
64 const response = await fetch('https://open.er-api.com/v6/latest/USD')
65 if (!response.ok) {
66 throw new Error(
67 `Currency rates request failed with status ${response.status}`,
68 )
69 }
70
71 const data = (await response.json()) as CurrencyRatesApiResponse
72 if (data.result !== 'success' || !data.rates) {
73 throw new Error('Currency rates response is invalid')
74 }
75
76 return data.rates
77}
78
79async function fetchCryptoRates(): Promise<Record<string, number>> {
80 const ids = Object.values(CRYPTO_IDS).join(',')

Callers 2

getCurrencyRatesFunction · 0.85
refreshFiatRatesForcedFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected