I am a beginner and trying to use firebase for my react native project authentication. I am able to authenticate user, print the user details and/or catch error if there is any while authenticating. But I am unable to return the value to another function. My project hierarchy: project |->utils/firebaseConnection.js |->Components/Login.js
This is my firebase authentication code:
export function loginUser (email,password) {
firebase.auth().signInWithEmailAndPassword(email,password)
.then(user => {
console.log('user: ', user)
return user
})
}
I am able to print user data in the console but I am not able to see the return value in Login component. Below is the code for login component method:
import * as firebaseAPI from '../utils/firebaseConnection'
...
...
loginUser (email,password) {
console.log('l1: ', firebaseAPI.loginUser(email,password));
}
but l1 prints "undefined". I even tried firebaseAPI.loginUser(email,password).then(user) , but even this yields undefined error. Please help me out. Thank you. I can give you more info if required.