2

I have a "/" route on my "events" router and the controller for that route just sends all event documents. I tried implementing another route so I can send only future events. The route is very similar to the base "/" but every time I try to call it I get a 403. I would even change it so that it's literally the same functionality as the "/" route or very similar and I would still get 403. I don't understand why the base route works but not this one. I tested it with a post instead of get it worked that time, but I don't understand why, because of how similar the controllers are.

export const getEvents = async (req, res, next) => {
    try {
        const events = await Event.find();
        res.status(200).json(events);
    } catch (err) {
        next(err);
    }
};



export const getFuture = async (req, res, next) => {
    try {
        let now = moment().toISOString();
        const events = await Event.find({date: { $gte: now}});
        res.status(200).json(events);
    } catch (err) {
        next(err);
    }
};

And here are the routes

router.get("/", getEvents);

router.get("/future", getFuture);

controllers are properly imported

ltmccarthy
  • 21
  • 3

0 Answers0