listCurrencies - Pricing Module Reference
BetaThis documentation provides a reference to the listCurrencies
method. This belongs to the Pricing Module.
This method is used to retrieve a paginated list of currencies based on optional filters and configuration.
Example
To retrieve a list of currencies using their codes:
import {
initialize as initializePricingModule,
} from "@medusajs/pricing"
async function retrieveCurrencies (codes: string[]) {
const pricingService = await initializePricingModule()
const currencies = await pricingService.listCurrencies(
{
code: codes
},
)
// do something with the currencies or return them
}
To specify attributes that should be retrieved within the money amounts:
import {
initialize as initializePricingModule,
} from "@medusajs/pricing"
async function retrieveCurrencies (codes: string[]) {
const pricingService = await initializePricingModule()
const currencies = await pricingService.listCurrencies(
{
code: codes
},
{
select: ["symbol_native"]
}
)
// do something with the currencies or return them
}
By default, only the first 15
records are retrieved. You can control pagination by specifying the skip
and take
properties of the config
parameter:
import {
initialize as initializePricingModule,
} from "@medusajs/pricing"
async function retrieveCurrencies (codes: string[], skip: number, take: number) {
const pricingService = await initializePricingModule()
const currencies = await pricingService.listCurrencies(
{
code: codes
},
{
select: ["symbol_native"],
skip,
take
}
)
// do something with the currencies or return them
}
Parameters
filters
FilterableCurrencyPropsThe filters to apply on the retrieved currencies.
filters
FilterableCurrencyPropsconfig
FindConfig<CurrencyDTO>The configurations determining how the currencies are retrieved. Its properties, such as select
or relations
, accept the
attributes or relations associated with a currency.
config
FindConfig<CurrencyDTO>select
or relations
, accept the
attributes or relations associated with a currency.Returns
The list of currencies.
Was this section helpful?