Saturday, 22 April 2017

"Cannot read property 'username' of undefined" - it IS defined?

I have the following index.pug file on my server that I am trying to render:

block content
    h1.
        User List
          ul
            each user, i in userlist
              li
                a(href="mailto:#{user.username}")= user.username

And my node.js app's code:

app.get('/sign-up', function(req, res) {
var db = req.db
var collection = db.get('_User')
collection.find({},{},function(e,docs){
res.render('index', {"userlist":docs})})
})

I get the following error upon trying to open 'sign-up': "Cannot read property 'username' of undefined"

Why might I be getting this error? I do have the collection called '_User' and it has 'username' key in it.



via kupak12

No comments:

Post a Comment