Open Alpgul02 opened 4 years ago
. . . let article = new Article(); article.title = req.body.title; article.author = req.user._id; article.body = req.body.body; . . .
Here in router.post('/add',....
I get the error of "TypeError: Cannot read property '_id' of undefined".
But I can correctly login with user.
How to solve this?
_id is not a property defined by you. It is by default assigned to every entry. So it's not property but it's a key and can't be accessed like this.
Here in router.post('/add',....
I get the error of "TypeError: Cannot read property '_id' of undefined".
But I can correctly login with user.
How to solve this?