Can't get current user's email

I can’st get current user’s email


I did:

let Emailset = wixUsers.currentUser.getEmail();
$w("#Email").value = Emailset

but it’s empty in the input


I also tried:

let Userinfo = wixUsers.currentUser;
$w("#Email").value = Userinfo.email

it’s still empty.


Please teach me how can I get current user’s email.

Greetings,

You may have missed a note in the wix-users documentation:

" The APIs in wix-users are only partially functional when previewing your site. View a published version of your site to see their complete functionality."

See if logging into the published site has the same issue.