Hi, I'm trying to set a button to display the member's name when logged in. However, the code has broken the rest of my code and also does not work and I'm not sure why?
Would anyone have any ideas?
See code below.
export function myGetCurrentMemberFunction(options) { return currentMember.getMember(options) .then((member) => { if (wixUsers.currentUser.loggedIn) { var firstName = `${member.contactDetails.firstName}`; $w('#logIn').label = "hi" + firstName; } else { $w('#logIn').label = "login"; } return member; }) .catch((error) => { console.error(error); }) }
//.... function myGetCurrentMemberFunction() { return currentMember.getMember({fieldsets: [ 'FULL' ]}) //....
And add console.log() 's to locate the issue.
function myGetCurrentMemberFunction(options) { return currentMember.getMember(options) .then((member) => { if (member) { var firstName = member.contactDetails.firstName; $w('#logIn').label = "hi " + firstName; } else { $w('#logIn').label = "login"; } return member; }) .catch((error) => { console.error(error); }) }