5
下面是什么,我试图做
if (tempTreatment.groupId === undefined) {
// create new group
Meteor.wrapAsync(Meteor.call('createTreatmentGroup', salon, tempTreatment.groupName, tempTreatment.groupName));
// get group id
var getGroup = Meteor.wrapAsync(Meteor.call('getTreatmentGroup', salon, tempTreatment.groupName));
console.log(getGroup);
tempTreatment.groupId = getGroup._id;
}
我想synchronosly运行这两个Meteor.call
功能,但我得到undefined
上console.log(getGroup);
其shuold只返回一个对象。
在0.9.3中有[Meteor.wrapAsync](http://docs.meteor.com/#meteor_wrapasync),可以在任何地方使用。这是错误吗? – 2014-09-26 11:37:13
我没有注意到。我认为他们制作了Meteor.wrapAsync的客户端版本,以便使用它的代码可以放入共享文件夹中而不会触发错误,但实际上这是用于服务器的。如果没有提供回调,'wrapAsync'的客户端版本只是简单地定义一个标准的'logErr'回调来代替,它只是记录错误(如果存在):https://github.com/meteor/meteor/blob/ 9608e6205019b69a302cde62e21fcae1c7d22e3d /包/流星/ helpers.js#L108 – saimeunt 2014-09-26 12:12:53