I have a issue, i'm trying to write my own firebase fonctions using firebase code. The thing is im using react and i need to retrive data from THEN method and returning doesnt work
CodePudding user response:
You must return the base async function. So, put the return
keyword before signInWithEmailAndPassword
function.
CodePudding user response:
One way is to use promises. This will return the value of the user after the function is ready.
Good luck!
const auth_connectedUser = (auth, email, password) => {
return new Promise((resolve, reject) => {
signInWithEmailAndPassword(auth, email, password)
.then(user => {
console.log(user)
return resolve(user)
}).catch(err => {
return reject(new Error(err))
})
})
}
const authUser = await auth_connectedUser(auth, email, password)
<iframe name="sif1" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>