Can you help me refactor the code below to use a callback function instead? I want to ensure that the Req and Res logic is handled separately.
Userservice.js
function getByUserId(req, res, next) {
let userIDD = req.body.userID;
User.findOne({
userID: userIDD
}, function(err, result) {
if (err) {
console.log("error: " + err)
} else {
console.log("Great!");
res.send(result)
}
})
}
UserRoute.js
router.post('/publicUser/getByUserID', userService.getByUserId)