//get Logged in user orders
exports.myOrders = catchAsyncErrors(async (req, res, next) => {
const orders = await Order.find({ user: req.user._id });
res.status(200).json({
success: true,
orders,
});
});
const express = require("express");
const { isAuthenticatedUser, authorizeRoles } = require("../middleware/auth");
const {
newOrder,
getSingleOrder,
myOrders,
} = require("../controller/orderController");
const router = express.Router();
router.route("/order/new").post(isAuthenticatedUser, newOrder);
router
.route("/orders/:id")
.get(isAuthenticatedUser, authorizeRoles("admin"), getSingleOrder);
//getting error in this /orders/me route
router.route("/orders/me").get(isAuthenticatedUser, myOrders);
module.exports = router;
image of the postmen when i try to access the orders when loged In
I was trying to get all the orders by the logged in user but getting an error in the routing