Meteor.user() returns undefined after page reload

做~自己de王妃 提交于 2019-12-05 05:14:51

It's better to use !!Meteor.userId() to check if a user is logged in, because there's no latency while waiting for the user data to be loaded from the server. In fact, Meteor.user routine is more or less equivalent to:

function () {
  return Meteor.users.findOne({ _id: Meteor.userId() });
}

which explains why it may return undefined even if the user is logged in.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!