Am I using the event correctly to update the token?

Viewed 38

The code I use in conjunction with RT-QUERY.

It seems to work, but I'm not sure if I'm using the event correctly.

const app = initializeApp(firebaseConfig);
export const auth = getAuth(app);
onIdTokenChanged(auth, (user) => { // обновление токена
  console.log(user);
  if (user) {
    console.log(user);
    getIdToken(user, true).then(r => {
      console.log(r);
      return ls.set('token', r);
    });
  }
  return null;
});
0 Answers
Related