-
Notifications
You must be signed in to change notification settings - Fork 66
Open
Description
The client receives a 500 response even though the code execution has not finished.
GET
`routerGET.get(async (req, res) => {
try {
const storeId = res.params.storeId;
const { searchParams } = new URL(req.url);
const categoryId = searchParams.get('categoryId') || undefined;
const colorId = searchParams.get('colorId') || undefined;
const sizeId = searchParams.get('sizeId') || undefined;
const isFeatured = searchParams.get('isFeatured');
const products = await prismadb.product.findMany({
where: {
storeId,
categoryId,
colorId,
sizeId,
isFeatured: isFeatured ? true : undefined,
isArchived: false,
},
include: {
images: true,
category: true,
color: true,
size: true,
},
orderBy: {
createdAt: 'desc',
}
});
const response = FormateResponse.success({
message: 'Products',
data: { products }
});
return NextResponse.json(JSON.stringify(response), { status: response.statusCode });
} catch (error) {
console.log('[PRODUCTS_GET]', error);
return new NextResponse("Internal error", { status: 500 });
}
// Adicione um retorno no final da função, caso nenhum dos retornos anteriores seja alcançado.
return new NextResponse("Internal error", { status: 500 });
})`
Metadata
Metadata
Assignees
Labels
No labels


