Getting user email as property instead of promise

Hi WIX team,

When user is logged in, I would like to show user’s email on page header.

Doing it in async way, I add the following code on the site:
if (wixUsers.currentUser.loggedIn) {
wixUsers.currentUser.getEmail().then((email) => {
$w(“#email”).text = email;
}).catch((err) => $w(“#email”).text = “”);
}
However after page loaded, it takes about 3 seconds till user email is shown. And it doesn’t look fine.

Doing same with waiting till promise resolved (await for example) to show email immediately makes the page load slower (blocked till promise is resolved).

Is it possible to get user’s email as property, similar to user ID, instead having to get it from promise?

Thanks,
Dima

2 Likes

I have no delay when displaying the user email on the header, I just run it on the site code not the page code…

Mike, as I wrote, I add this code on site, not on page. Again, it is possible to wait till promise is resolved on site, then to proceed to further actions. However in this case the entire page load time is longer, as well mostly site rendered then in one cycle on frontend. And in this case you lose the advantage of using rendering cycles and displaying heavy page faster when it is rendered both on server and on browser.