Is there any possibility of calling a server method from within a observe
callback in Meteor?
I put together an example that reproduces the issue, that
Btw Tarang's answer also works when calling from a client method. Essentially I have a file in the client scope. And this file is a method definition. Inside my method definition I call a method at the server.
I was having problems because only the client stub of the server call is being called and the server method does not get called. The fix was this one:
Meteor.methods({
assignUserSession: function(options) {
setTimeout(function() { // https://stackoverflow.com/questions/18645334/meteor-meteor-call-from-within-observe-callback-does-not-execute
// Find all the base_accounts of this user and from there decide which view to prioritize.
Meteor.call('user_base_accounts', {user_id: Meteor.userId()}, function(error,result){
....
//server is then called due to logs shown in the command prompt
....
});
});
}
});
Thanks for pointing this out!