getConversionRate( )


Gets a currency conversion rate.

The getConversionRate() function returns a Promise that resolves to a ConversionRate object, which contains the currency conversion rate between two currencies. The exchange rates are provided by XE on a daily basis and include the timestamp when they were set.

Note: By using this function you agree to XE's Terms of Use.

Method Declaration
Copy
function getConversionRate(
  sourceCurrency: string,
  targetCurrency: string,
): Promise<ConversionRate>;
Method Parameters
sourceCurrencystringRequired

Currency to convert from.


targetCurrencystringRequired

Currency to convert to.

Returns
Return Type:Promise<ConversionRate>
Return the conversion rate and timestamp.
JavaScript
import { currencies } from "wix-pay-backend"; currencies.currencyConverter .getConversionRate("USD", "GBP") .then((conversionRate) => { const rate = conversionRate.rate; const timestamp = conversionRate.timestamp; }); /* conversionRate: * { * "rate": 0.8152242392, * "timestamp": "2020-03-15T20:00:00.181Z" * } */
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?