Javascript – Why does it only work correctly when I use the await keyword?
try { const review = await Review.create({ user: user.userid, place_id: pid, stars: stars, content: content, }); /* await */ User.findByIdAndUpdate(user.userid, { $push: {reviews: review._id} }); res.status(200).json(returnResponse(false, "reviewWritten", "-")); return; } catch (error) { console.error(error); res.status(500).json(returnResponse(true, "errorAtReviewWriting", "-")); return; } I…