Exception in template helper returning user-document-data

Hi,

I have a custom field “customData” in my user document.
I keep getting an exception in my client-console regarding this template helper although the data is showed correctly.

template.x.helpers({
  customData: function() {
    return Meteor.users.findOne().customData;
  }
});

what is causing this “issue”? I appreciate any input.

Meteor.users is reactive and your helper is probably called more than once. I bet Meteor.users.fondOne() returns null at one of the calls

how would you resolve that issue?

template.x.helpers({
  customData: function() {
    var user = Meteor.users.findOne();
    return user ? user.customData : null;
  }
});
1 Like