When I'm trying to get data I got undefined, but in one second after recalling the method again I get what I want. How I understand, I just wait for a response and when I try to return an object, I have nothing because it is on his way to me. .findOne() hasn't callback, what I can do in this situation?
handleLogin = () => {
Meteor.loginWithPassword(this.state.loginField,this.state.passwordField,(error)=>{
if (!error) {
Meteor.subscribe('xxx')
let data = Meteor.collection('xxxy').findOne();
console.log(data);
}
}
}