Answers for "cannot use getidtoken if null"

0

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)
  });
}
Posted by: Guest on April-06-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language