Skip to main content
Skip to main content

retrieveCurrency - Pricing Module Reference

Beta

This documentation provides a reference to the retrieveCurrency method. This belongs to the Pricing Module.

This method retrieves a currency by its code and and optionally based on the provided configurations.

Example

A simple example that retrieves a currency by its code:

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function retrieveCurrency (code: string) {
const pricingService = await initializePricingModule()

const currency = await pricingService.retrieveCurrency(
code
)

// do something with the currency or return it
}

To specify attributes that should be retrieved:

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function retrieveCurrency (code: string) {
const pricingService = await initializePricingModule()

const currency = await pricingService.retrieveCurrency(
code,
{
select: ["symbol_native"]
}
)

// do something with the currency or return it
}

Parameters

codestringRequired
The code of the currency to retrieve.
The configurations determining how the currency is retrieved. Its properties, such as select or relations, accept the attributes or relations associated with a currency.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

PromisePromise<CurrencyDTO>Required
The retrieved currency.
Was this section helpful?