【发布时间】:2017-12-18 12:29:53
【问题描述】:
好吧,我有一个用户模型需要实现 customToJSON 并删除要返回 json 的对象的密码。 当我将“responseType”作为“json”放入“exits”时,一切正常,并且密码从响应中取出。但是, responseType: "json" 将根据发送 responseType 为空的终端中的消息而被弃用,但不会调用 customToJSON。谁能帮我理解这个?
这是型号代码:
[...]
attributes: {
name: {
type: 'string',
required: true,
},
email: {
type: 'string',
required: true,
},
password: {
type: 'string',
minLength: 6,
required: true,
},
},
customToJSON: function() {
return _.omit(this, ['password']);
},
[...]
这是操作代码:
module.exports = {
friedlyName: 'Users List',
description: 'User list -> all users',
exits: {
success: {
}
},
fn: async (inputs, exits) => {
var users = await User.find();
return exits.success(users);
}
}
如果您输入“responseType: 'json'”,这就是消息:
json响应类型将在即将发布的版本中弃用。请改用 ``(标准)(即从success退出中删除responseType。)
【问题讨论】:
标签: javascript node.js express sails.js