Undefined UserId
Undefined UserId
So I am trying to do a 1v1 chat but the userid is showing up as undefined when I push up the message, and the other-other users id doesn't show.
if (user.emailVerified) {
userPic = user.photoURL;
userId = user.id;
displayName = user.displayName;
var pm = database.ref('chat/' + userId);
// Create a new message and add it to the list.
pm.push({
displayName: displayName,
userId: userId,
pic: userPic,
text: myString.toString(),
timestamp: new Date().getTime(), // unix timestamp in milliseconds
})
}
This is is the code I am using to push the message up
Edit
This is the userID I am talking about
Undefined UserId
user.id
userId
UserId
undefined
ljhgwvliueghgl
Are you sure that user object contains id?
– Kasabucki Alexandr
Jun 30 at 7:15
console.log(user)
... what do you see?– Jaromanda X
Jun 30 at 7:15
console.log(user)
May be you need to access to userId like this user.userId instead user.id
– Kasabucki Alexandr
Jun 30 at 7:54
Can you try using
database.ref().child('chat').child(userId)
instead of database.ref('chat/' + userId )
?– André Kool
Jun 30 at 8:32
database.ref().child('chat').child(userId)
database.ref('chat/' + userId )
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
you say
Undefined UserId
... but there's onlyuser.id
or the globaluserId
- so where is thisUserId
that isundefined
- certainly not in your code - except of course it would be, but then so isljhgwvliueghgl
as that too isn't ever assigned a value– Jaromanda X
Jun 30 at 7:14