Skip to content

UseGetExchangeRate

katanakit-js / useGetExchangeRate

function useGetExchangeRate(from, to): Promise<SafeResult<number>>;

Defined in: infrastructure/currency/currency.service.ts:95

Returns the exchange rate between two currencies.

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.

Promise<SafeResult<number>>

{ data, error, ok } — never throws.

import { useGetExchangeRate } from "katanakit-js";
const rate = await useGetExchangeRate("USD", "EUR");
if (rate.ok) console.log(rate.data); // 0.88865