I'm trying to set a session variable inside a callback function as such:
getPlayerName() {
Meteor.call("stocks.getPlayer", this.props.player.player, function(error, result){
if(error){
console.log(error.reason);
return;
}
Session.set('playerName', result.Name);
});
console.log(Session.get('playerName'));
}
But the console on the client side returns undefined. I've also tried using reactive variables:
getPlayerName() {
this.name = new ReactiveVar();
Meteor.call("stocks.getPlayer", this.props.player.player, function(error, result){
if(error){
console.log(error.reason);
return;
}
this.name.set(price);
}.bind(this));
console.log(this.name.get());
}
But this also returns undefined. How can I get this to work? Thank in advance.