Listing of all users in the users collection not working first time with meteor js

前端 未结 1 404
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-06 14:51

I am having the issue with listing all the user\'s in the users collection. When I take the listing page, only the currently logged in user\'s details are shown. But all us

1条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-06 14:59

    It sounds like a race condition with the subscription (it runs before the user is logged in). I'd recommend putting your subscription inside of an autorun:

    Tracker.autorun(function() {
      if (Meteor.user()) {
        Meteor.subscribe('userList');
      }
    });
    

    This has the additional benefit of not starting your subscription before the user is logged in (saves resources).

    BTW, I can't think of a reason why you'd need the this.stop() and the end of your publish function.

    0 讨论(0)
提交回复
热议问题