this.userId in Methods not Working in Server Calls

Hi, I have defined a method in which only this.userId value is returned.
And I called this method on the server, and it returned the null method, which means no user has logged in.
Whereas, when I call this method in the client, it returns the user’s ID.
What does this really mean ??

this is my code in Server StartUp :

Meteor.methods({
	GetCurrentUser (){
	    return this.userId;
	},
});
Meteor.call('GetCurrentUser',(er ,re)=>{
	console.log(re);
});
1 Like

If you call this method from the server there shouldn’t be any value for this.userid as the call is not associated or originating from a particular user.

I have used this pattern before to check if the server made the call or a client.

4 Likes