davehowson/chat-app

TypeError: Cannot read property 'userId' of null

uma-08 opened this issue · 1 comments

do you got any idea on this error?
(Error in ChatBox.js)
Screenshot 2021-02-21 at 11 14 36 PM

your mongoose model query function Users.find() gives you an array of objects So if you want to Access it the way you have used try like this

Users.findOne({userid:xxx},callback);
or you have to access the array index if you use it find() method

Users.find({userId:xxx},(users)=>{users[0]==neededId}