currency-exchange-rate
Version:
Completely free NPM library to get realtime Currency Exchange Rate
17 lines (16 loc) • 583 B
JavaScript
var currencyExchangeRate = require("./currency-exchange-rate.js");
//Using a Promise.
currencyExchangeRate.getCurrencyExchangeRate({ fromCurrency: "USD", toCurrency: "INR" }).then(function (exchangeRateValue) {
console.log(exchangeRateValue);
}).catch((error) => {
console.log(error);
});
//Using a callback function.
currencyExchangeRate.getCurrencyExchangeRate({ fromCurrency: "USD", toCurrency: "INR" }, function (exchangeRateValue, error) {
if (error) {
console.error(error);
}
else {
console.log(exchangeRateValue);
}
});