findItemById
Method finding item based on provided ID in Bloomreach Discovery.
This method sends a GET request to the search endpoint of the Vue Storefront API Middleware. In turn, it receives data from the Bloomreach GraphQL Commerce API using findItemById query.
You can use this method to fetch information about certain item.
Signature
declare function findItemById(
params: QueryParams<QueryFindItemByIdArgs>
): Promise<Item>;Parameters
| Name | Required | Type | Description |
|---|---|---|---|
params | Required | QueryParams<QueryFindItemByIdArgs> | Check the type for more information. |
Returns
Returns an item.
Referenced Types
Examples
Fetching item by ID.
import { sdk } from '~/sdk';
const id = '4654916';
const item = await sdk.brd.findItemById({ id });Fetching item by ID with only specified fields.
import { sdk } from '~/sdk';
const id = '4654916';
const item = await sdk.brd.findItemById({
id,
expect: `
itemId {
id
}
`
});Fetching item by ID passing query hint.
import { sdk } from '~/sdk';
const id = '4654916';
const item = await sdk.brd.findItemById({
id,
queryHint: {
brUid2: 'some value'
}
});