cannot use getidtoken if null code example
Example: cannot use getidtoken if null
// get the current user inside the observer
// then refresh the token
// and finally unsubscribe the observer
const getIdTokenRefreshed = async () => {
return new Promise(async (resolve, reject) => {
const unsubscribe = firebase
.auth
.onAuthStateChanged(user => {
unsubscribe()
const refreshedToken = await user
.getIdToken(true)
.catch(err => console.error(err))
resolve(refreshedToken)
}, reject)
});
}