Meteor.user query error

How can i return an account query like in the example below with out getting an error.
var user_id = Meteor.userId();
var thumb_Id = Meteor.users.findOne({_id:user_id},{“profile.Thumbnail_URL”:1});
Session.set(‘image_id’, thumb_Id.profile.Thumbnail_URL);
I get the folowing error if i try this code:
Uncaught Error: Can’t call non-function: undefined
Exception in callback of async function: TypeError: Cannot read property ‘profile’ of undefined
at null. (http://localhost:3000/app/layout.js?


var thumb_Id = Meteor.users.findOne({_id:userid},{"profile.Thumbnail_URL":1});

MongoDB’s ids always start with an underscore, so it has to be _id instead of id.

1 Like

Thank you waldgeist. I have corrected the issue.

1 Like