Hi everyone. I’m trying to make it so certain items on the page show up if you have a role. First step is to check and see if roles even are working with my code. I tried to set text80 to the user’s role. For some reason text80 is not showing the role. Why is this? Is there anything I could do to fix this?
My full code.
let user = wixUsers.currentUser;
let userId = user.id; //
let isLoggedIn = user.loggedIn; // true
console.log(user);
console.log(userId);
console.log("isLoggedIn = " + isLoggedIn );
user.getEmail()
.then( (email) => {
let userEmail = email; // "user@something.com"
console.log(userEmail);
} );
user.getRoles()
.then( (roles) => {
$w("#text80").text = roles;
let firstRole = roles[0];
let roleName = firstRole.name; // "Role Name"
let roleDescription = firstRole.description; // "Role Description"
console.log (roles);
console.log (firstRole);
console.log (roleName);
console.log (roleDescription);
} );