I have two main folders that have to do with the issue: routes and controller. In the routes folder, I declare the paths and also call the corresponding controller:
router.get('/my-route', testController.method);
And in the controller I'm using jwt to verify the token of the current user:
testController.method= verifyToken , (req, res) => {
res.send("test")
};
This returns 404 error.
However, if I cut the "res.send" and I paste it in the verifyToken method, it returns 200 + "test", so it just ignores what happens after the verifyToken function(?)
However, when I join the route and the controller in the same file, it works just fine. Something just like this:
router.get('/my-route', verifyToken, (req, res)=>{
res.json("test")
});
I'm pretty sure that I'm not moving around the files well (the verifyToken is a function located in another file in the controllers folder), but I am fairly new to js, so I'm not sure why is this happening.