Skip to content

Commit faacafb

Browse files
committed
fix: handle 404
1 parent b8efac8 commit faacafb

File tree

1 file changed

+6
-7
lines changed
  • src/app/(main)/products/[handle]

1 file changed

+6
-7
lines changed

src/app/(main)/products/[handle]/page.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@ type Props = {
88
}
99

1010
export async function generateMetadata({ params }: Props): Promise<Metadata> {
11-
const { products } = await getProductByHandle(params.handle).catch((err) => {
12-
console.error(err)
13-
notFound()
14-
})
11+
const data = await getProductByHandle(params.handle)
1512

16-
const product = products[0]
13+
const product = data.products[0]
14+
15+
if (!product) {
16+
notFound()
17+
}
1718

1819
return {
1920
title: `${product.title} | Acme Store`,
@@ -32,7 +33,5 @@ export default async function CollectionPage({ params }: Props) {
3233
notFound()
3334
})
3435

35-
console.log(products)
36-
3736
return <ProductTemplate product={products[0]} />
3837
}

0 commit comments

Comments
 (0)