Meteor: "exception in template helper" -
i have basic post stream running in meteor pulls posts
collection. template feed following template helper reaches collection:
template.poststream.helpers({ /* supplies posts collection client * view. */ postsstream: function(){ var loggeduser = meteor.user(); return posts.find({ userid: loggeduser._id }); }, });
the helper seems work fine , posts appear expected. however, vague error in console , can't work out how clear it: exception in template helper: postsstream@http://localhost:3000/client/views/stream/post-stream.js?37c902af708ff817888efc24c4e45f352cfb6884:6:41
character 6:41 corresponds midway through loggeduser._id
string. what's going on?
when first running application, helper executed meteor.user()
returning null
because login resume process takes few milliseconds.
you need guard prevent access loggeduser._id
, otherwise you'll exception.
return posts.find({ userid: loggeduser && loggeduser._id });
Comments
Post a Comment