Implementing Firebase authentication on my website, I'm looking to pass the user const into Express for routing purposes. Here's the function responsible for creating a new user:
const signupForm = document.getElementById('signup');
if (signupForm) {
signupForm.addEventListener('submit', (e)=>{
e.preventDefault();
const email = signupForm.email.value;
const password = signupForm.password.value;
createUserWithEmailAndPassword(auth, email, password)
.then((cred)=>{
return cred.user;
})
signupForm.reset();
})
}
However, every time I try to require anything from the firebase file in Express, I encounter the following error message:
const signupForm = document.getElementById('signup'); ^ ReferenceError: document is not defined
I am aware that this error arises due to the fact that the document object is associated with the DOM and cannot be used in Express. Is there a way for me to solely export the user const into Express? Any assistance would be greatly appreciated. Thank you.