mirror of
https://github.com/vercel/commerce.git
synced 2025-07-25 11:11:24 +00:00
refactor catalog products API method
Signed-off-by: Loan Laux <loan@outgrow.io>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import catalogItemsQuery from '@framework/utils/queries/catalog-items-query'
|
||||
import { normalizeProduct } from '@framework/utils'
|
||||
import type { ProductsEndpoint } from '.'
|
||||
import type { ProductsEndpoint } from './products'
|
||||
|
||||
const getCart: ProductsEndpoint['handlers']['getProducts'] = async ({
|
||||
req,
|
||||
@@ -15,9 +15,13 @@ const getCart: ProductsEndpoint['handlers']['getProducts'] = async ({
|
||||
},
|
||||
})
|
||||
|
||||
const products = catalogItems.map((item) => normalizeProduct(item))
|
||||
const products = catalogItems?.edges?.map(({ node }) => normalizeProduct(node))
|
||||
|
||||
res.status(200).json({ data: products ?? null })
|
||||
res.status(200).json({
|
||||
data: {
|
||||
products: products ?? null
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export default getCart
|
Reference in New Issue
Block a user