Skip to content
Advertisement

firebase.auth().currentUser.uid showing previous uid

I’m trying to set user data into the realtime database. To do that I want the uid of the current user who is logged in. But when I use the firebase.auth().currentUser.uid; I’m getting the previous uid.

Here’s the code:

JavaScript

Don’t mind the (*) in the config, I just don’t want to show that information.

Advertisement

Answer

If you want to get the UID of the current user right after they signed in, you can get if from cred:

JavaScript
Advertisement