I want to use observe for one of my collection on the server but I need to get userId,
I'm trying to use this.userId
and also Meteor.userId()
but not working! see the below code for more detail and error message
how to resolve it ?
Messages.find({state:"outbox"}).observe({
added: (doc) => {
console.log(" observe ");
console.log("userId : " + this.userId); // undefined
console.log("Meteor.userId(): " + Meteor.userId()); // "Exception in queued task: Error: Meteor.userId can only be invoked in method calls. Use this.userId in publish functions."
//.......
}
});
thanks for you attention.