UNPKG

@rathmika/currencyconverter

Version:
9 lines (7 loc) 350 B
async function convertCurrency(amount, from, to) { const response = await fetch(`https://v6.exchangerate-api.com/v6/4f13c7ffd80d489ecc1f2039/latest/${from}`); const data = await response.json(); const rate = data.rates[to]; return rate ? (amount * rate).toFixed(2) : "Invalid Currency"; } export default { convertCurrency };