The use of callback functions has been deprecated in the latest version of Mongoose.
we need to use either Promises or async/await syntax.
Particularly if Model.find throws an error then we can replace it as follows.
Model.find().then((err, data) => {
if(err){
return res.send(err)
}
return res.json(data)
});