Mongoose - findByIdAndUpdate - doesn't work with req.body

后端 未结 3 1986
孤街浪徒
孤街浪徒 2021-02-14 17:57

I have a problem with update documents in mongodb over mongoose.

My model bellow:

var mongoose = require(\'mongoose\');
var bcrypt = require(\'bcrypt-nod         


        
3条回答
  •  难免孤独
    2021-02-14 18:20

    I found the mistake. Note that I'm calling

    req.body.user_id

    where should be

    req.params.user_id

    • url is (PUT) http://127.0.0.1:3000/api/users/54724d0fccf520000073b9e3

提交回复
热议问题