I am getting an Exception whenever a user logged in into his account, and I cant see the collection data until the page is been refreshed… **[but I am not getting any exception if i use it like
’’’
Books.find({“customer_name”:this.userId);
‘’'
instead of
‘’’
Books.find({“customer_name”:Meteor.user().emails[0].address);
‘’'
and i dont need that step because in my app users collection finding should be based on there email id not by userId…]**
my code is shown below :
Some one please help me out
server - main.js:
‘’’
var My_collection;
Meteor.publish(‘books’, function() {
My_collection = Books.find({“customer_name”:Meteor.user().emails[0].address);
return My_collection;
‘’’
client -main.js:
‘’’
Template.viewBooks.helpers({
books() {
return Books.find({}, { sort: { books_order: -1 } }).fetch();
},
});
‘’’
client - main.html
‘’’
{{#each books}} {{books_id}} {{/each}}
‘’’
ERROR:
App running at: http://localhost:3000/
I20171205-16:06:49.773(5.5)? Exception from sub transactions id wQ9DpjjABEiPzMZ9P TypeError: Cannot read property ‘emails’ of null
I20171205-16:06:49.872(5.5)? at Subscription._handler (server/main.js:16:75)
I20171205-16:06:49.873(5.5)? at maybeAuditArgumentChecks (packages/ddp-server/livedata_server.js:1768:12)
I20171205-16:06:49.873(5.5)? at DDP.CurrentPublicationInvocation.withValue (packages/ddp-server/livedata_server.js:1043:15)
I20171205-16:06:49.873(5.5)? at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1134:15)
I20171205-16:06:49.873(5.5)? at Subscription.runHandler (packages/ddp-server/livedata_server.js:1041:51)
I20171205-16:06:49.873(5.5)? at packages/ddp-server/livedata_server.js:826:41
I20171205-16:06:49.874(5.5)? at Function..each..forEach (packages/underscore.js:147:22)
I20171205-16:06:49.874(5.5)? at packages/ddp-server/livedata_server.js:822:9
I20171205-16:06:49.874(5.5)? at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1134:15)
I20171205-16:06:49.874(5.5)? at Session._setUserId (packages/ddp-server/livedata_server.js:816:34)