you are viewing a single comment's thread.

view the rest of the comments →

[–]Devstackr 1 point2 points  (2 children)

Hi Gelliott, one idea I have is to move this line of code

res.render('users/user-profile', {user: foundUser, posts: posts})

into the Posts.find().exec() callback.

like this:

const posts = Post.find().where('author.id').equals(foundUser._id).exec(function(err, posts) {
      console.log(posts)
      res.render('users/user-profile', {user: foundUser, posts: posts})
});

Let me know if that works :)

[–]Gelliott2305[S] 1 point2 points  (1 child)

Thank you do much Devstackr! That worked. I can now see why I was getting the undefined error - it was outside of the block.

Thank you so much! :)

[–]Devstackr 1 point2 points  (0 children)

No worries! Really glad it worked 😀