当我试图获取数据时,我得到了未定义的数据,但是在再次调用该方法后一秒钟,我得到了我想要的。我的理解是,我只是等待响应,当我尝试返回一个对象时,我什么都没有,因为它正在向我走来。.findOne() 没有回调,在这种情况下我能做什么?
handleLogin = () => {
Meteor.loginWithPassword(this.state.loginField,this.state.passwordField,(error)=>{
if (!error) {
Meteor.subscribe('xxx')
let data = Meteor.collection('xxxy').findOne();
console.log(data);
}
}
}