Issue getting current role and pricing plan of a user.

I am working on a referral system for my site, and am trying to get the hang of retrieving information that i will need. (I am not a coder but i am working on it, LOL) So far i am able to get the user ID and email but following the same format i cannot get the role and Pricing plan. What am i doing wrong? I have checked that the text box names are correct.

import wixUsers from ‘wix-users’;

// …
$w.onReady( function () {

let user = wixUsers.currentUser;

let userId = user.id; // “r5cme-6fem-485j-djre-4844c49”
let isLoggedIn = user.loggedIn; // true

user.getEmail()

.then( (email) => {
let userEmail = email; // “user@something.com
$w(‘#text20’).text = email;
} );

user.getRoles()
.then( (roles) => {
let firstRole = roles[0];
let roleName = firstRole.name; // “Role Name”
let roleDescription = firstRole.description; // “Role Description”
$w(‘#text22’).text = roles;
} );

user.getPricingPlans()
.then( (pricingPlans) => {
let firstPlan = pricingPlans[0];
let planName = firstPlan.name; // “Gold”

let startDate = firstPlan.startDate; // Wed Aug 29 2018 09:39:41 GMT-0500 (Eastern Standard Time)
let expiryDate = firstPlan.expiryDate; // Thu Nov 29 2018 08:39:41 GMT-0400 (Eastern Daylight Time)
$w(‘#text21’).text = firstPlan.name;
} );

$w(‘#text19’).text = user.id;

});

bump

Can anyone help with this?

Roles is a object and you can’t set an object to a text parameter. You need to use the below.

$w('#text22').text = roles; // This will not work
$w('#text22').text = firstRole.name;   // This will work