@padmesh123/currency-convertor
Version:
An npm package to convert currency using FreeCurrencyAPI.
30 lines (23 loc) ⢠764 B
Markdown
A simple and lightweight NPM package for converting currency using [FreeCurrencyAPI](https://freecurrencyapi.com/).
---
```bash
npm install @padmesh123/currency-convertor
š Usage
js
Copy
Edit
import Freecurrencyapi from '@everapi/freecurrencyapi-js';
const freecurrencyapi = new Freecurrencyapi('YOUR_API_KEY_HERE');
async function convertCurrency(fromCurrency, toCurrency, units) {
const res = await freecurrencyapi.latest({
base_currency: fromCurrency,
currencies: toCurrency
});
const multiplier = res.data[toCurrency];
return multiplier * units;
}
// Example:
const amount = await convertCurrency("INR", "USD", 3);
console.log(amount);