I'm trying to return the profile.name from a meteor user from an ID passed in from a template.
I've made a template helper that calls a meteor method (as I know to get to users other than the logged in one I need to be on the server) and have confirmed that the user ID is being passed correctly, but it blows up with the find query (or findOne) returning undefined.
The method looks like
hostUser: function(userID) {
//var id = _.pick(attribs, 'userID');
console.log(userID);
var user = Meteor.users.find({_id: userID});
console.log(user);
return user.profile.name;
}
which is within Meteor.methods in the /lib directory
The console.log(userID) call is correct, but the find (or findOne) returns null.
db.users.findOne({_id:"sAhoXRtwqkDyMwK9"}) returs the correct user (if run from the mongo console).
findwithfindOneand do:Meteor.call('hostUser', 'sAhoXRtwqkDyMwK9', function(err, name){console.log(err, name);});- David WeldonTemplate.projectPage.helpers ({ posterUserName: function() { Deps.autorun(function() { console.log(this.userID); Meteor.call('hostUser', this.userID, function (error, result) { if(error) { throwError(error.reason); } else { console.log("Result:"+result.profile.name); return result.profile.name; } }); }) } })Formatting is all over the place.. but the first console.log is never displayed and undefined returned - Peter Nunn