With async / await the code that is typically in the promise callback can be moved out- so instead oftake this section for example:
I haven’t tested this code but my guess is that the call to .populate('category')
comes after the callback where res.render()
is called - so that may be a bug.
It can be like simplified to something like this:
Though maybe the call to populate the category needs to come after the value from Post.find({})
Is assigned to posts
.