currency-exchange-rate

1.0.9 • Public • Published

currency-exchange-rate

NPM library to get realtime Currency Exchange Rate from Yahoo Finance Website. This library uses axios under the hood to make HTTP Call to Yahoo Finance.

Parameters

fromCurrency and toCurrency are two mandatory properties for config parameter of getCurrencyExchangeRate(config, callbackFunction(exchangeRateValue, error)) function. The currency symbols are ISO 4217 Currency Codes. You must pass valid values for these 2 config properties, otherwise the library function will retun error. You can optionally use any of the axios request config along with fromCurrency and toCurrency

If you are using the library behind a coporate proxy please refer axios request config properties link on how to set your proxy settings.

Usage

var currencyExchangeRate = require("currency-exchange-rate");
//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);
    }
});

Package Sidebar

Install

npm i currency-exchange-rate

Weekly Downloads

2

Version

1.0.9

License

BSD-2-Clause-FreeBSD

Unpacked Size

7.46 kB

Total Files

5

Last publish

Collaborators

  • sribasu