Node.js 使用node&;构建restapi;Express.js,我的PUT方法没有';因为某种原因我不能工作。有人能帮我吗?

Node.js 使用node&;构建restapi;Express.js,我的PUT方法没有';因为某种原因我不能工作。有人能帮我吗?,node.js,mongodb,express,mongoose,postman,Node.js,Mongodb,Express,Mongoose,Postman,我的数据模型: var UserDetail = new Schema({ username: String, password: String }, { collection: 'userInfo' }); var UserDetails = mongoose.model('userInfo', UserDetail); 这是我在routes文件中的post方法 //POST router.post( '/api/users', funct

我的数据模型:

var UserDetail = new Schema({
      username: String,
      password: String
    }, {
      collection: 'userInfo'
    });
var UserDetails = mongoose.model('userInfo', UserDetail);
这是我在routes文件中的post方法

//POST
router.post( '/api/users', function( req, res ) {
    var user = new UserDetails({
        username: req.body.username,
        password: req.body.password
    });
    console.log(req.body.username);
    user.save( function( err ) {
        if( !err ) {
            console.log( 'created' );
            return res.send( user );
        } else {
            console.log( err );
            return res.send('ERROR');
        }
    });
});
我的get api工作得很好。josn看起来像这样:

{"username":"exmpleUsername","password":"examplePassword","_id":"54091d9df8f00fb42055b6f8","__v":0}
但是当我尝试使用POSTMAN发布时,它没有添加用户名和密码。它只是添加了新的_id,如下所示:

{"_id":"540e394f37706f701020cf19","__v":0}

提前谢谢

请检查您的模式类的用户名和密码是否是私有的

var Schema = function(){

    var self = this;

    var username = ""; // mean private

    self._id = ""; // mean public

};

谢谢,但你说的“身份证”是什么意思?