Sails.js ReferenceError:用户api中未定义用户

Sails.js ReferenceError:用户api中未定义用户,sails.js,Sails.js,当我打开localhost:1337/user时,我得到了内部服务器错误 这里有些不对劲 ReferenceError:未定义用户 我怎样才能修好它?我的API不工作。我无法使用sailsjs中的html表单在数据库中插入数据。 我的用户模型是: module.exports = { attribute: { firstname: { type: 'string', unique: true }, lastname: { type: 'strin

当我打开
localhost:1337/user
时,我得到了内部服务器错误 这里有些不对劲

ReferenceError:未定义用户

我怎样才能修好它?我的API不工作。我无法使用sailsjs中的html表单在数据库中插入数据。 我的用户模型是:

    module.exports = {
    attribute: {
 firstname: {
    type: 'string',
    unique: true
  },
  lastname: {
    type: 'string',
    unique: true
},
 organisationName: {
    type: 'string',
    unique: true
},
 DepatmentName: {
    type: 'string',
    unique: true
},
 DOB: {
    type: 'date',
    unique: true
},
 DOJ: {
    type: 'date',
},
 DOL: {
    type: 'date',
},
 Address: {
    type: 'string',
},
 City: {
    type: 'string',
},
 State: {
    type: 'string',
},
 Country: {
    type: 'string',
},
  email: {
    type: 'string',
    email: true,
    required: true,
    unique: true
    },
    encryptedPassword: {
        type: 'string',
    },
    ContactNumber: {
        type: 'integer',
    },
    //toJSON: function() {
//      var obj = this.toObject();
//
//  }
}
};

您正在调用一个变量“user”,但该变量不存在或为空。检查此变量的代码


在youre usermodel中,您只有firstname和lastname。我想你需要这个。如果您需要更具体的帮助,那么您必须向我们展示页面的一些额外编码,而不仅仅是模型。

现在api工作不正常。当我输入这个:然后我得到了{“id”:2}我看不出你的控制器是做什么的。因为在controller.sole.info(“程序启动”)中调用用户的方式很可能导致问题;module.exports={'new':函数(req,res){res.view();},操作:函数(req,res,next){var params=req.body;//创建用户。查找(params,函数(err,createdData){if(err){res.badRequest({error:err});}其他{return res.json({status:“success”,data:createdData});}}}}}我怀疑您的req.body包含不同的格式,因此当您使用User.find使用req.body中的参数时,sails return referenceError请告诉我使用表单在mysql数据库中插入数据的基本控制器代码。