Inconsistent Input into database field

I am pulling the email of the person logged-in to place the email in a field of a database record along with selections from drop-downs. The problem I am having it the email is added sometimes but not all of the time. Below is the code for my page. I am new at coding so be gentle. Any help would be greatly appreciated

import wixData from ‘wix-data’;
import wixUsers from ‘wix-users’;

let user = wixUsers.currentUser;
let userId = user.id;
let isLoggedIn = user.loggedIn;

user.getEmail()
.then( (email) => {
let userEmail = email;
$w(“#voteemail”).value = userEmail;
console.log(userEmail);
} );

$w.onReady(function () {

});

export function Start_click(event) {
//Add your code for this event here:
$w(‘#firstchoice’).enable();
}

export function firstchoice_click(event) {
//Add your code for this event here:
$w(‘#secondchoice’).enable();
}

export function secondchoice_click(event) {
//Add your code for this event here:
$w(‘#submitvote’).show();
}

Hi,
I see that you are using the getEmail() function outside the onReady() function. This might cause it’s inconsistent work.

The APIs in wix-users can only be used once the page has loaded. Therefore, you must use them in code that is contained in or is called from the onReady() event handler or any element event handler.