Can't get email out of user

The email is undefined.
Why ?

My code:
let url = “https://myserver.com:443/api/someapi”;

let user = wixUsers.currentUser;

let userId = user.id; //there is one
let isLoggedIn = user.loggedIn; //true
let userEmail;
user.getEmail()
.then( (email) => {
userEmail = email; // “user@something.com
} );

If you have simply copy pasted the code from the Documentation it will not work. You need to read the docs to understand how to use the code.

Once you figure out user.getEmail(), this will help you with “phones”
https://www.wix.com/corvid/forum/main/comment/5d3402a9967b610017b16eab

Maybe something like this may help.

var login = await wixUsers.login(email, password)
 						 
var user = wixUsers.currentUser;
const userId = user.id; 		// "r5cme-6fem-485j-djre-4844c49" 
var isLoggedIn = user.loggedIn; 	// true, false
var userEmail = "";			// initialize
console.log("Login = " + login + " " , user);
console.log("userID = " + userId + " " , user);
console.log("isLoggedIn = " + isLoggedIn + " " , user);

if ( isLoggedIn ){			// if true

	try {
		const getEmail = await user.getEmail();
		if ( getEmail ) {	// if true (email available)

			userEmail = getEmail;  // "user@something.com"
									
			console.log("===> User is logged in " + userId);
			console.log("===> User email " + userEmail);

			// do your stuff ...
			}

		} // end "try"
		catch(error) {
			console.log("get user.getEmail Failed.");
		}

	} else {	// end if (isLoggedIn )

	// not logged in:
	console.log("User not logged in.");
	// handle this ...
}