79090149

Date: 2024-10-15 13:28:10
Score: 0.5
Natty:
Report link

The problem was on getStaticPaths function, instead of passing the id, I passed the object

export async function getStaticPaths() { 
   const productsIds = await prisma.product.findMany(); 
   return {
      paths: productsIds.map((id) => ({
      params: { id: id.toString() },
    })),
fallback: true, // false or "blocking"
};

The correction:

export async function getStaticPaths() {
const productsIds = await prisma.product.findMany({
    select: {id: true},
  });

  return {
    paths: productsIds.map((product) => ({
      params: { id: product.id.toString() },
    })),
    fallback: 'blocking', // false or "blocking"
  };
}
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Lucas Chini