Search code examples
expresspostpostmanbackend

POSTMAN is showing findByIdAndUpdate is not a function


Error in Postman

This is my Code:

My Code

Server is starting successfully, without syntactical errors

tried searching for bugs, but couldnt find anything, changed name of models, tried restarting IDE and POSTMAN


Solution

  • i think the correct method name is findByIdAndUpdate as follows

    const updatedPost = await Post.findByIdAndUpdate(
      post,
      { $push: { comments: savedComment._id } },
      { new: true }
    )
    

    you might need to capitalize the 'a' in 'and' as it is not recognized