Uncaught (in promise) -19976 (user registration)

Hi guys !

I have been working all day on understanding what is wrong with my code, and I can’t figure it out :cry:

If someone can help, I would be so glad ! So, we are here on the “sign up” lightbox, where the user will register. What I want is that :
1 - Password, email and phone are stored in the PrivateMemberData → the user is registered
2 - Based on the email of the user, I run a query in order to extract his contactID
3 - I store the contactID with other information related to the user in a new database (Profil patient)
4 - I log the user in
5 - I redirect the user to a welcome lightbox

You can run the code using the following link : https://valentinloppe.wixsite.com/oncopole
You go to “connexion”, then you click on “je n’ai pas encore de compte”

Now, here is my code :

import wixUsers from 'wix-users';
import wixData from 'wix-data';
import wixLocation from 'wix-location';
import wixWindow from 'wix-window';
import { session } from 'wix-storage';

$w.onReady(function () {

    $w('#button2').onClick(() => {
 if ($w("#firstName").value === "") {
            $w("#text13").text = "Merci de renseigner votre prénom"
            $w("#text13").expand()
        } else if ($w("#lastName").value === "") {
            $w("#text13").text = "Merci de renseigner votre nom de famille"
            $w("#text13").expand()
        } else if ($w("#cps").value === "") {
            $w("#text13").text = "Merci de renseigner votre numéro de CPS"
            $w("#text13").expand()
        } else if ($w("#datePicker1").value === "") {
            $w("#text13").text = "Merci de renseigner votre date de naissance"
            $w("#text13").expand()
        } else if ($w("#email").value === "") {
            $w("#text13").text = "Merci de renseigner votre adresse email"
            $w("#text13").expand()
        } else if ($w("#password").value === "") {
            $w("#text13").text = "Merci de renseigner votre mot de passe"
            $w("#text13").expand()
        } else if ($w('#checkbox1').checked) {
 let emails = [];
 let labels = [];
            finale()

        } else {
            $w('#text13').expand();
        }
    });
});

export function text14_click(event) {
    wixWindow.lightbox.close()
    wixWindow.openLightbox("Connection")
}

function connection() {

 let email = $w('#email').value
 let password = $w("#password").value

    wixUsers.login(email, password)

        .then(() => {
            console.log("User is logged in");
            session.setItem("prenom", $w('#lastName').value);
            wixWindow.openLightbox("Bienvenue")
        })
}

function register() {
 let [email, password, phones, firstName, lastName] = [$w('#email').value, $w('#password').value, [$w('#phoneNumber').value], $w('#firstName').value, $w('#lastName').value];
    wixUsers.register(email, password, {
 "contactInfo": {
 "firstName": firstName,
 "lastName": lastName,
 "phones": phones
        }
    })
}

function savings() {

    wixData.query("Members/PrivateMembersData")
        .eq("loginEmail", $w('#email').value)
        .find()
        .then((results) => {
 let Result = results.items[0]
 let ResultID = Result._id;
            console.log(ResultID)

            $w("#dataset1").setFieldValues({
 "nom": $w('#firstName').value,
 "prenom": $w('#lastName').value,
 "cps": $w('#cps').value,
 "telephone": $w('#phoneNumber').value,
 "email": $w('#email').value,
 "dateDeNaissance": $w('#datePicker1').value,
 "patientId": ResultID
            })
            $w("#dataset1").save()
            session.setItem("ResultID", ResultID);

        })

}

async function finale() {
 await register()
    console.log("l'utilisateur est enregistré")
 await savings()
    console.log("les données sont stockées")
    connection()

}

Thank youuuu <3

up ?