I can’t log out on Firebase

Asked

Viewed 26 times

0

Hello I have an application where the person connects by firebase until then nothing else because this is already configured and working, so I created this button in case the person wants to end the session: <button onclick="logout()">logout</button>

this button calls the logout function that is like this:

function logout(){
  firebase.auth().signOut().then(function(){
            console.log('success');
            window.location.replace("Login");
        },function(){})
    }

but he doesn’t give Logout what’s wrong?

1 answer

0


Hi,

  • First careful when doing that <button onclick="logout()">logout</button>
    Why? Because when javascript is reading the code that comes from LEFT TO RIGHT AND TOP TO BOTTOM, it will see the method logout() already running! so it on first read already running the code.
  • I was taking a look at the documentation and your code is almost great! Look at how it looks in the comments:
firebase.auth().signOut().then(function () {

}).catch((error) => {
  // An error happened.
});
  • The difference is that you are passing a species of callback, and this may be bugging your script, I believe that if you follow this documentation can give a different result, follow the link: Docs singOutFibase

Browser other questions tagged

You are not signed in. Login or sign up in order to post.