I have running in my Mac a Node.JS server, and, I access to it from other computer, the server doesn't crash, but, I don't know why, the application crashes when I access from my iPad. If I access from Safari, the server works, but, with Chrome for iPad, the app crash!
This is the error: TypeError: Cannot read property 'following' of null
. Why this happens?
EDITED:
app.get('/home', middleware.yeses, function (req, res){
console.log(req.session.user + "\n\n");
UserModel.find({ user: req.session.user }, function (err, user){
console.log(user);
res.render('home.ejs', {
username: req.session.user,
avatar: user[0].avatar,
following: user[0].following.length,
followers: user[0].followers.length
});
});
});
EDITED:
I changed the console.log(user);
to this console.log(user[0].following)
. And there's no problem. I don't know why, there's a problem with it in the locals.