UseGetExchangeRate
katanakit-js / useGetExchangeRate
Function: useGetExchangeRate()
Section titled “Function: useGetExchangeRate()”function useGetExchangeRate(from, to): Promise<SafeResult<number>>;Defined in: infrastructure/currency/currency.service.ts:95
Returns the exchange rate between two currencies.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
from |
| "USD" | "EUR" | "GBP" | "JPY" | "CHF" | "CAD" | "AUD" | "NZD" | "MXN" | "BRL" | "ARS" | "COP" | "CLP" | "SEK" | "NOK" | "DKK" | "PLN" | "CZK" | "HUF" | "RON" | "TRY" | "ISK" | "CNY" | "HKD" | "SGD" | "INR" | "KRW" | "THB" | "IDR" | "MYR" | "PHP" | "ILS" | "ZAR" |
Source currency. |
to |
| "USD" | "EUR" | "GBP" | "JPY" | "CHF" | "CAD" | "AUD" | "NZD" | "MXN" | "BRL" | "ARS" | "COP" | "CLP" | "SEK" | "NOK" | "DKK" | "PLN" | "CZK" | "HUF" | "RON" | "TRY" | "ISK" | "CNY" | "HKD" | "SGD" | "INR" | "KRW" | "THB" | "IDR" | "MYR" | "PHP" | "ILS" | "ZAR" |
Target currency. |
Returns
Section titled “Returns”Promise<SafeResult<number>>
{ data, error, ok } — never throws.
Example
Section titled “Example”import { useGetExchangeRate } from "katanakit-js";
const rate = await useGetExchangeRate("USD", "EUR");if (rate.ok) console.log(rate.data); // 0.88865