diff --git a/src/controllers/CartController.ts b/src/controllers/CartController.ts index 2e13696..3dbd652 100644 --- a/src/controllers/CartController.ts +++ b/src/controllers/CartController.ts @@ -12,7 +12,7 @@ export async function addToCart(req: Request, res: Response) { res.status(400).json({ error: 'Product id is required.' }); return; } - let cart: ICart = await Cart.findOne({ userId }); + let cart: ICart | null = await Cart.findOne({ userId }); if (!cart) { cart = await Cart.create({ userId,