cannot use getidtoken if null

Solutions on MaxInterview for cannot use getidtoken if null by the best coders in the world

showing results for - "cannot use getidtoken if null"
Juan Manuel
24 Jul 2020
1// get the current user inside the observer
2// then refresh the token
3// and finally unsubscribe the observer
4const getIdTokenRefreshed = async () => {
5  return new Promise(async (resolve, reject) => {
6     const unsubscribe = firebase
7     	.auth
8     	.onAuthStateChanged(user => {
9          unsubscribe()
10          const refreshedToken = await user
11              .getIdToken(true)
12              .catch(err => console.error(err))
13          resolve(refreshedToken)
14     }, reject)
15  });
16}