I am new to meteor. and I am trying to display some user information on webpage and here is the html:
<div>
<span id="login-entrance">{{loginEntranceContent}}</span>
</div>
Here is the client side js:
Template.body.helpers({
loginEntranceContent(){
if (Meteor.userId()==null) {
return 'Log in/Sign up';
} else {
Meteor.user().emails.address;
};
},
});
While the Meteor.userId() worked(I can get the value of _Id of the user) but the Meteor.user() returned undefined(and it didn’t refresh it). And I know it must be the problem of DOM rendered before data was ready. I thought the data binding and update was automatically accomplished. how did it happen?
I have go round in meteor forum and stackoverflow forum. there are some similar topics but none of them have provide clear explain and simple solution.
All I want is to display the current login user information. Can anyone give me any clue?