The situation to implement is the following.
I want to fetch the email-address used for a social login while presing an button.
I can see that after the social login the contact is updated/created in the contacts of the site including the emailaddress but for some reason my “userEmail” remains empty.
Any advise?
My code:
export function button7_click_1(event, $w) {
console.log('button7 test')
let user = wixUsers.currentUser;
let userId = user.id;
let isLoggedIn = user.loggedIn;
var firstRole;
var userEmail;
var roleName;
var roleDescription;
user.getEmail()
.then( (email) => {
userEmail = email;
} )
.catch(error => {
console.log(error)
});
user.getRoles()
.then( (roles) => {
firstRole = roles[0];
roleName = firstRole.name; // "Role Name"
roleDescription = firstRole.description; // "Role Description"
} );
console.log(user)
console.log(userId)
console.log(isLoggedIn)
console.log(firstRole)
console.log(userEmail)
console.log(roleName)
console.log(roleDescription)
}
Thanks!
Kr
Tim