Constructor
new Exchange(coinsopt)
Create a new Exchange Rate checker
Example
import Exchange from 'oip-exchange-rate';
let exchange = new Exchange();
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
coins |
CoinObject |
<optional> |
Object containing CoinsObjects |
Methods
(async) getExchangeRate(coin, fiat) → {Promise.<number>}
Parameters:
Name | Type | Description |
---|---|---|
coin |
string |
The string coin name (ex. "bitcoin") |
fiat |
string |
The string fiat (ex. "usd") |
Example
import Exchange from 'oip-exchange-rate';
let exchange = new Exchange();
exchange.getExchangeRate("bitcoin", "usd").then((rate) => {
console.log(rate);
})
Returns:
Returns a Promise that will resolve to the number value of the exchange rate
- Type:
- Promise.<number>