There are no errors in my code and it's a simple mongoose query -
const posts = await Post.find();
console.log(posts);
res.status(200).json({
status: 'success',
results: posts.length,
data: {
posts,
},
});
I've checked the collection in compass and even added some data. However, when I make the request, the response is -
{
"status": "success",
"results": 0,
"data": {
"posts": []
}
}