简体   繁体   中英

Firebase giving 404 error in the console when signing in through wrong email and password

I'm using Firebase in a React app. I have implemented a sign-in component and when I try to use wrong email and password, it gives an error message in the console which looks like something

 auth.js:204 POST https://www.googleapis.com/identitytoolkit/v3/relyingparty/verifyPassword?key=AIzaXXXX9YaDiUUiA_n8L_Rs89YYYY 400

My sign-in code looks like

await app.auth().signInWithEmailAndPassword(email, password).then(() => {
            setLoading(false);
            setOpen({
                isOpen: true,
                message: 'Logged In Successfully',
                type: 'success'
            });
        }).catch(e => {
            setLoading(false);
            setOpen({
                isOpen: true,
                message: e.message,
                type: 'error'
            });
        });

Here you can see that I'm using catch to handle the error so why it is showing in the chrome console as a 404 error?

You're mixing async / await syntax with then() . Just use one or the other. Something like this should work fine:

const signInUser = async (email, password) => {
  try {
    await auth().signInWithEmailAndPassword(email, password);
    setLoading(false);
    setOpen({
        isOpen: true,
        message: 'Logged In Successfully',
        type: 'success'
    });
  } catch (error) {
       setLoading(false);
       setOpen({
           isOpen: true,
           message: e.message,
           type: 'error'
       });
    }
};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM