'How to Fix Error: Firebase: Error (auth/api-key-not-valid.-please-pass-a-valid-api-key.)?
When I am trying to create a new user for the first time, error: Firebase: Error (auth/api-key-not-valid.-please-pass-a-valid-api-key.) error appears.
https://i.stack.imgur.com/217k3.png
const Registration = () => { const [ createUserWithEmailAndPassword, user, loading, errorEmailAndPassword ] = useCreateUserWithEmailAndPassword(auth,{sendEmailVerification:true}); const [ updateProfile, updating, errorUpdateProfile ] = useUpdateProfile(auth); const [ signInWithGoogle, Googleuser, Googleloading, Googleerror ] = useSignInWithGoogle(auth);
const nameRef = useRef('');
const emailRef = useRef('');
const passRef = useRef('');
let location = useLocation();
const [agree, setAgree] = useState(false);
const navigate = useNavigate();
let from = location.state?.from?.pathname || "/";
let errorEvent;
const handleRegistration = async (event) =>{
event.preventDefault();
const name = nameRef.current.value;
const email = emailRef.current.value;
const password = passRef.current.value;
await createUserWithEmailAndPassword(email, password);
await updateProfile({ displayName:name });
console.log('Updated profile');
console.log(user);
}
if (Googleerror || errorEmailAndPassword) {
errorEvent = <p className='text-danger'>Error:{Googleerror?.message} {errorEmailAndPassword?.message}</p>
}
const navigateRegister =()=>{
navigate('/Login');
}
if(user){
navigate('/');
console.log(user);
}
if (Googleuser || user) {
navigate(from, { replace: true });
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
