retrieveInventoryItem - Inventory Module Reference
This documentation provides a reference to the retrieveInventoryItem
method. This belongs to the Inventory Module.
This method is used to retrieve an inventory item by its ID
Example
A simple example that retrieves a inventory item by its ID:
import {
initialize as initializeInventoryModule,
} from "@medusajs/inventory"
async function retrieveInventoryItem (id: string) {
const inventoryModule = await initializeInventoryModule({})
const inventoryItem = await inventoryModule.retrieveInventoryItem(id)
// do something with the inventory item or return it
}
To specify relations that should be retrieved:
import {
initialize as initializeInventoryModule,
} from "@medusajs/inventory"
async function retrieveInventoryItem (id: string) {
const inventoryModule = await initializeInventoryModule({})
const inventoryItem = await inventoryModule.retrieveInventoryItem(id, {
relations: ["inventory_level"]
})
// do something with the inventory item or return it
}
Parameters
inventoryItemId
stringRequiredThe ID of the inventory item to retrieve.
config
FindConfig<InventoryItemDTO>The configurations determining how the inventory item is retrieved. Its properties, such as select
or relations
, accept the
attributes or relations associated with a inventory item.
config
FindConfig<InventoryItemDTO>select
or relations
, accept the
attributes or relations associated with a inventory item.context
SharedContextA context used to share resources, such as transaction manager, between the application and the module.
context
SharedContextReturns
The retrieved inventory item.
Was this section helpful?