Search...
getConversionRate( )
Gets a currency conversion rate.
Description
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.
Syntax
function getConversionRate(sourceCurrency: string, targetCurrency: string): ConversionRate
getConversionRate Parameters
NAME
TYPE
DESCRIPTION
sourceCurrency
string
Currency to convert from.
targetCurrency
string
Currency to convert to.
Returns
Fulfilled - The conversion rate between the source and target currencies and the timestamp when the rate was set.
Return Type:
Promise<ConversionRate>
NAME
TYPE
DESCRIPTION
rate
number
The conversion rate between the source and target currencies.
timestamp
Date
The date and time when the rate was set.
Was this helpful?
Return the conversion rate and timestamp.
Copy Code
1import {currencies} from 'wix-pay-backend';23currencies.currencyConverter.getConversionRate("USD", "GBP")4 .then((conversionRate) => {5 const rate = conversionRate.rate;6 const timestamp = conversionRate.timestamp;7 });89/* conversionRate:10 * {11 * "rate": 0.8152242392,12 * "timestamp": "2020-03-15T20:00:00.181Z"13 * }14 */