Beginning of ecommerce
This commit is contained in:
16
src/lib/product-by-handle.tsx
Normal file
16
src/lib/product-by-handle.tsx
Normal file
@ -0,0 +1,16 @@
|
||||
import { cache } from 'react';
|
||||
import { medusaClient } from '@/lib/config';
|
||||
import { PricedProduct } from '@medusajs/medusa/dist/types/pricing';
|
||||
|
||||
export const getProductByHandle = cache(async function (
|
||||
handle: string,
|
||||
): Promise<{ product: PricedProduct }> {
|
||||
const product = await medusaClient.products
|
||||
.list({ handle })
|
||||
.then(({ products }) => products[0])
|
||||
.catch((err) => {
|
||||
throw err;
|
||||
});
|
||||
|
||||
return { product };
|
||||
});
|
||||
Reference in New Issue
Block a user