'Meteor.user().emails[0].address' returns TypeError


#1

Hi.
I tried to get email address in the object 'Meteor.user()'
var address = Meteor.user().emails[0].address;
if (address == ‘hoge@hoge.com’) { … }
and I got what I want. My progran run as I expected.

But, on the console (client side, chrome Javascript console), I saw a warning like
’Exception in template helper: TypeError: Cannot read property ‘emails’ of undefined’
or sometimes
’Exception in template helper: TypeError: Cannot read property ‘emails’ of null’

Would anyone tell me What happend ? and how I fix it ?