I have a Meteor.publish
in my code, that calls another function, that calls another one, and so on. Then, in the most inner function, I need to know what user is the active one.
Meteor.user()
can't be used. It says
Meteor.userId can only be invoked in method calls. Use this.userId in publish functions.
and this.userId
is not acessible inside the inner function.
What can be done then?
Can't you just assign this.userId
to a variable within the publish method and then pass that variable around?
Meteor.publish("my_channel", function() {
var userId = this.userId;
myFunction(userId);
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With