Help with getMember()

I want to extract the data from a few fields from a member’s stored profile/contact data, which are:

firstName, lastName & aboutMember (this is a custom field)

and trust me when I say that i have spent literal hours to work on this system. I will tell you what I have:

currentMember.getMember()
    .then((member) => {
        var fullName = `${member.contactDetails.firstName} ${member.contactDetails.lastName}`;
        var about = member.contactDetails.aboutMember;
        console.log(fullName);
    })

This code works very well and does return the fullName in the form of a string, which is EXACTLY what I desire. The issue is, I am unable to store the string into a variable and use it outside this function :frowning: I want to be able to use fullName because I want to submit it to the site in the form of a string. Secondly, ‘about’ is throwing an error, saying that

Property 'aboutMember' doesn't exist on ContactDetails.

which I think might be due to the fact that it is a custom field, but then what is the workaround? I was unable to understand the docs, so I am asking this question here.

Now, I have also tried something which might be a possible solution:

var x = currentMember.getMember().then( (member) => `${member.contactDetails.firstName} ${member.contactDetails.lastName}`);
console.log(x);

Though this does return the correct fullName, it’s returning a promise within which there is a value. The value is correct, but I need it in the form of a string, because I have to put it into a collection later.

I am seriously exhausted now, I even tried getting the value and storing it in local storage but it didnt work for some reason. Thanks a lot in advance for any help you all provide! Please ask any questions because I dont post here much so this might not be a good explanation.

Check the following post, maybe it can help you…