0

I have a basic query to get the email list of the people in my database. When I console.log() it through console, it works great, but within the app it just doesn't.

// this works in console.log() but not in the app
return memberProfile.findOne({memberId: Meteor.user()._id}).email

// this is how its meant to be, where we insert each appropriate user id
return memberProfile.findOne({memberId: this._id}).email

I'm still getting the hang of Meteor, would much appreciate your help with learning it.

Mike
  • 1
  • 1
    My guess is: first time when data is not available yet, your findOne will not find anything and will return undefined? try `var doc = memberProfile.findOne({memberId: this._id}); return doc ? doc.email : "placeholder@mail.com"` – imslavko Jul 14 '14 at 17:14
  • I suspect Slava is correct. Reading [this post](https://dweldon.silvrback.com/guards) may be beneficial. – David Weldon Jul 14 '14 at 17:50
  • Another great article David. – Mike Jul 14 '14 at 18:13

0 Answers0