UNPKG

wgo-databank

Version:
35 lines 1.39 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.getGlobalCurrencies = void 0; /** * The Frankfurter API tracks foreign exchange references rates published by the European Central Bank. * https://www.frankfurter.app/docs/ */ const apiUrl = 'https://api.frankfurter.app'; const axios_1 = __importDefault(require("axios")); const getGlobalCurrencies = async () => { const response = await axios_1.default.get(`${apiUrl}/currencies`); const jsonData = response.data; if (!jsonData) throw `Currency Service - getGlobalCurrencies: Impossible to retrieve currency list from api.`; const jkeys = Object.keys(jsonData); const currencies = []; for (let i = 0; i < jkeys.length; i++) { const key = jkeys[i]; const description = jsonData[key]; if (!description) { console.error(`Currency Service - getGlobalCurrencies: invalid description on currency: ${key}`); return; } currencies.push({ code: key, description: description, }); } return currencies; }; exports.getGlobalCurrencies = getGlobalCurrencies; //# sourceMappingURL=CurrencyFurterService.js.map