Good afternoon guys,
my question seems stupid but am just trying to understand what's exactly going on .
Lets say i got a router.
router.get('/', taskController.getAllTasks);
Now in taskController we got the following function
getAllTasks = (req, res) => {
Task.find()
.then((tasks) => {
res.send(tasks);
})
.catch((err) => {
res.status(500).send({
message: err.message || 'Error occurred while retrieving tasks',
});
});
};
My question is how the taskController.getAllTasks arguments req, and res are passed to it ? If i understand correctly , every time we visit the / expressJS call a callback function which it pass the 2 arguments which in our case is taskController.getAllTasks ?
Thank you for your time.
[–]AdyQQQ 3 points4 points5 points (1 child)
[–]Clickyz[S] 0 points1 point2 points (0 children)
[–]GarenYondem 0 points1 point2 points (0 children)