I'm trying to return the userRecord from inside the getUserRecordFromAuth
function in firebase and to use it to get the user's UID
from Authentication in Firebase.
The problem is that the userRecord.uid is always returning undefined
, even though I'm returning the value of the promise in the getUserRecordFromAuth()
. What gives?
const getUserData = mobile => {
const userRecord = getUserRecordFromAuth(mobile);
console.log('uid', userRecord.uid);
}
const getUserRecordFromAuth = mobile => {
const promise = auth.getUserByPhoneNumber(mobile);
return promise.then(userRecord => {
return userRecord;
}).catch(error => {
console.log(error);
});
}