Everything was running smoothly until I suddenly encountered this error message: ReferenceError: next is not defined. I'm puzzled because I didn't make any changes to this function.
const Users = require('../data/users.model')
exports.addUser = (req, res) => {
const newUser = new Users({
Username: req.body.Username,
Password: req.body.Password,
UserType: req.body.UserType,
Email: req.body.Email,
Age: req.body.Age,
Answer1: req.body.Answer1,
Answer2: req.body.Answer2,
Answer3: req.body.Answer3,
});
newUser.save((err) => {
if (err){
return next(err);
//error occurs at this point^
}
res.send('User account created successfully');
});
};