Mongoose stopped accepting callbacks for some of its functions

MongooseError: Model.find() no longer accepts a callback

Since the callback function has been deprecated from now onwards.
If you are using these functions with callbacks, use async/await or promises if async functions don’t work for you.

app.get("/articles", async (req, res) => {
  try {
    const articles = await Article.find({ });
    res.send(articles);
    console.log(articles);
  } catch (err) {
    console.log(err);
  }
});

Leave a Comment