
throw new MongooseError('Query.prototype.exec() no longer accepts a callback');
^
MongooseError: Query.prototype.exec() no longer accepts a callback
I was trying to register users.
I had this same issue and fixed it with two solutions:
npm uninstall mongoose
npm install [email protected]
myModel.find({}).exec((err, res) => {
//callback code
});
Just remove your .exec() function and replace it with .then()/.catch():
myModel.find({}).then((res) => {
//if succeded do this block of code
}).catch((err) => {
//catch error
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With