Blank document and unhandled promise rejection when making an add subdocument request

Instead of fetching and then updating the document you can directly update the document in one DB call."/update/:id",(req, res) =>{
    var greek = req.body.greek;
    var english = req.body.english;
    var success = req.body.success;
    var timeStamp = req.body.timeStamp
    var newWord = {
        greek: greek,
        english: english,
        success: success,
        timeStamp: timeStamp
    User.findOneAndUpdate({ _id: }, {
            $push: {
                words: newWord
    .then((user) => {
                return res.status(404).json({ 
                    message: 'Not User matches given ID'

    .catch((err) => {res.status(400).json("Error: "+err)})

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top