ReferenceError:用户api中未定义用户

时间:2017-05-16 07:43:38

标签: sails.js

当我打开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();
//
//  }
}
};

1 个答案:

答案 0 :(得分:0)

您正在调用变量“user”,它不存在或者为空。检查这个变量的代码..

在您的用户模型中,您只有名字和姓氏。我想你需要其中一个。如果您需要更具体的帮助,那么您必须向我们展示一些额外的页面编码,而不仅仅是模型。