I'm trying to access the this.userId variable from a call to Meteor.methods, but it doesn't seem to work when I try to call a method through Meteor.setTimeout or Meteor.setInterval.
This is what I have:
if (Meteor.is_server) { Meteor.methods({ getAccessToken : function() { try { console.log(this.userId); return Meteor.users.findOne({_id: this.userId}).services.facebook.accessToken; } catch(e) { return null; } } }); var fetch_feed = function() { console.log(Meteor.call("getAccessToken")); [...]
Watching the terminal log, this.userId always returns zero. But if I try to call the method from the client side or through the console, it will return the correct identifier.
Why does this not work from Meteor.setInterval? Is this a mistake or am I doing something wrong?
source share