Member based search results

I think issue related to the initialization. You are trying to call backend “getEmail” function before $w.onReady (or it is not guaranteed that wixUser. currentUser.id returns you user id.

Something like this can work for you. (copy/pasted with minor changes)

let email;

$w.onReady(function(){
    initElements();
    let user = wixUsers.currentUser;
    if(user.loggedIn) { 
           let userId = wixUsers.currentUser.id;
           return getEmail(userId).then((emailquery) => { 
               email = emailquery;
           })
     }
});

Additionally just interesting why you are not using wix getEmail standard function in client side?
https://www.wix.com/velo/reference/wix-users/user/getemail
It seems you are using current user member, so it can very useful.