convertAmounts( )


Converts an array of amounts from one currency to another.

Use the convertAmounts() function to convert an array of one or more amounts between two currencies. The convertAmounts() function returns a Promise that resolves to a ConvertedAmounts object which contains an array of converted amounts and the timestamp for the conversion rate used.

Note: The currency codes used must exist in the array returned by the getAllCurrencies() function.

Method Declaration
Copy
function convertAmounts(
  options: ConvertAmountsOptions,
): Promise<ConvertedAmounts>;
Method Parameters
optionsConvertAmountsOptionsRequired

Currencies and amounts to convert.

Returns
Return Type:Promise<ConvertedAmounts>
Convert an array of amounts from one currency to another.
JavaScript
import { currencies } from "wix-pay-frontend"; const conversionOptions = { amounts: [1.0, 2.5, 5.3], from: "USD", to: "GBP", }; currencies.currencyConverter .convertAmounts(conversionOptions) .then((convertedAmounts) => { const firstConvertedAmount = convertedAmounts.amounts[0]; const timestamp = convertedAmounts.timestamp; }); /* * { * "amounts":[0.8149261982, 2.0373154955, 4.31910885046], * "timestamp": "2020-03-15T21:00:00.277Z * } */
Errors

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

Did this help?