@rathmika/currencyconverter
Version:
A simple currency converter using exchange rate.
10 lines (8 loc) • 362 B
JavaScript
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";
}
const index = { convertCurrency };
export { index as default };