【发布时间】:2015-07-02 12:58:30
【问题描述】:
我正在尝试调用服务器方法来返回是否存在隐藏属性。该属性在终端控制台中正确返回,但在客户端未正确返回(返回未定义)。我要返回的属性是tireMarkup。
这是我的方法调用:
var currentUserId = this._id;
Meteor.call('checkMarkup', currentUserId, function(tireMarkupExists) {
console.log(tireMarkupExists) //returns undefined
if(!tireMarkupExists) {
alert('Please enter a tire markup greater than 1 for the customer');
alert(tireMarkupExists) //returns undefined
}
这是我的服务器方法:
Meteor.methods({
'checkMarkup': function(currentUserId, tireMarkupExists) {
console.log('user? ' + currentUserId); //returns the correct user
a = Meteor.users.findOne(currentUserId);
console.log(a.tireMarkup); //returns the integer value correctly
if (a.tireMarkup & a.tireMarkup > 1) {
return (tireMarkupExists);
}
}
});
有什么想法吗?我认为问题与我传递 currentUserId 和 tireMarkupExists 参数的方式有关。
【问题讨论】:
标签: javascript meteor client server