How to connect Firebase and wix

Hii,
I have a few forms on my site and i’d like to submit the data to firestore. does anyone know how can this be achieved. I have tried directly writing javascript code in the on ready function

$w.onReady(function () {
  $w("#button14").onClick(() => { 
        console.log("button clicked");
         
        const email =  $w('#input4').value;
        const password =  $w('#input1').value;
        const nationalid=  $w('#input6').value;
        const code = $w('#dropdown2').value;
        const mobile =  $w('#input5').value;
        const dob =  $w('#datePicker2').value;
        const firstname =  $w('#input3').value;
        const lastname =  $w('#input2').value;
        
         auth.createUserWithEmailAndPassword(email, password)
            .then((function (userCredential){
                const user = userCredential.user;

                // Add user details to Firestore collection
                db.collection('landingpage-costumer').doc(user.uid).set({
                    nationalid,
                    code,
                    mobile,
                    dob,
                    email,
                    firstname,
                    lastname,
                });
                console.log('Registration successful.');
                console.log(user)
            })
            // .catch(function (error) { 
            //     // Handle Errors here.
            //     var errorCode = error.code;
            //     var errorMessage = error.message;
            //     console.log("Error: " + errorCode + ", " + errorMessage);
            // }));
			)
     })

});

})

The problem is this code doesn’t do anything and doesn’t even produce errors
can someone help?

It looks like you are trying to use JavaScript code to submit form data to Firestore on your website. Based on the code snippet you provided, there are a few possible reasons why the code might not be working as expected:

  1. Firebase Configuration: Make sure you have properly initialized Firebase in your project and that you have imported the required Firebase libraries. This includes importing Firebase Auth and Firestore in your JavaScript file.
  2. Check Firebase Console: Ensure that you have set up your Firebase project correctly, including setting up Firestore and enabling authentication. Double-check your Firestore database rules to make sure they allow the write operation for the ‘landingpage-costumer’ collection.
  3. Button Click Event: Ensure that the button with the ID “button14” is correctly connected to the click event handler in the Wix editor. Double-check that the event handler is associated with the correct function.
  4. Console Logging: Check the browser console (usually accessible by pressing F12) for any error messages or logs. It’s possible that there might be errors or warnings that can give you more information about what’s going wrong.
  5. Auth and Firestore Objects: Confirm that the ‘auth’ and ‘db’ objects are properly set up and referencing the Firebase Auth and Firestore instances. If you are using Wix, you might need to initialize Firebase with Wix-specific setup instructions.
  6. Debugging: You can add console.log statements throughout your code to check the values of variables and see if the code is reaching specific parts of the function.
    To further assist you, it would be helpful to know if you are using any libraries or frameworks (other than Firebase) and the structure of your HTML page. Additionally, if there are any error messages in the console, please provide them for better understanding.
    If you continue to face issues, consider reaching out to the Wix support community or Firebase support for specific help with integrating Firestore with Wix.
    MyLabCorp Portal

The problem is that console.logs aren’t getting executed so I can’t see anything in the console