My createUserWithEmailAndPassword function seems to be malfunctioning. Here is the code snippet I am using -
config.js
import firebase from 'firebase/app'
import 'firebase/firestore'
import 'firebase/auth'
const firebaseConfig = {
apiKey: "AIzaSyBD8W5T7ZSvryW2TNSWOgoCO3EpyV6i65o",
authDomain: "vue-firebase-site-eb79e.firebaseapp.com",
projectId: "vue-firebase-site-eb79e",
storageBucket: "vue-firebase-site-eb79e.appspot.com",
messagingSenderId: "657936011344",
appId: "1:657936011344:web:a2498d2fe27f951b6b8155"
};
firebase.initializeApp(firebaseConfig)
const projectAuth = firebase.auth();
const projectFirestore = firebase.firestore();
const timeStamp = firebase.firestore.FieldValue.serverTimestamp
export default { projectAuth, projectFirestore, timeStamp }
useSignUp.js
import { ref } from "vue"
import projectAuth from '../firebase/config'
const error = ref(null)
const signup = async (email,password,displayName) => {
error.value = null
try {
const res = await projectAuth.createUserWithEmailAndPassword(email, password)
console.log(res)
if(!res){
throw new Error('Could not complete the signup')
}
await res.user.updateProfile({displayName})
error.value = null
return res
} catch (err) {
console.log(err.message)
error.value = err.message
}
}
const useSignup = () =>{
return{error, signup}
}
export default useSignup
I have tried multiple troubleshooting steps including-
- Deleting node modules and reinstalling them.
- Updating the version of firebase library.
Unfortunately, none of these solutions seem to be working for me. Any help or suggestions would be greatly appreciated!
Thank you in advance!!