Problem with new API - wix-members

Until now I worked with Wix-users.login() and I didn’t had any problem. Now I changed to the new API wix-members.getMember and I’m getting an error when trying to get the user’s email:

$w . onReady (() => {

currentMember . getMember () 
    . then (( member ) => { 
        console . log ( member );  // In the console log I'm getting:  			
						"undefined" 
        loginEmail  =   member . loginEmail ;     //  In the console log  
				I'm getting an error: "TypeError:  
				Cannot read properties of undefined  
				(reading 'loginEmail')" " 
        loginName  =  ` ${ member . contactDetails . firstName } ${ member . contactDetails . lastName }`; 

And since this function called only after the user loged in, so it can’t be undefined!

I had a similar problem with this. However, it seems to be working for me… When it didn’t work, it actually would work on my login page, and what I did (then removed it since the function started working) was that I took I think the member object being returned on the login page and passed it using an exported function to the backend where it was saved to a variable. Then, when I wanted to use it again, I checked if getMember() was undefined, and if it was, I used the object stored in the backend by calling another exported function that simply returned the variable stored in the backend. Would you like to see the code?

1 Like

Oops, I am also getting undefined now :frowning:

$w.onReady(function () {
    currentMember.getMember()
        .then((member) => {
            console.log(member);
        })
});

Is logging undefined. What is the issue here?

Does anyone have any idea why this is happening and how to fix it? Is there no way other than what I said originally, which is to use the backend to store the data? After I reload, it works. I need this ASAP, thanks in advance.

You should try:

currentMember.getMember({fieldsets: ['FULL']})

P.S. But if the member itself logs undefined, that won’t help.

I did that, I’m still getting undefined, which shouldn’t happen, since it is running on the onReady of a members only page, so I’m definitely signed in… What’s more, when I refresh, it works. I really need this for something I need to get done ASAP.

@jonatandor35 What do you mean by the ‘member logging undefined’?

Bump, I need help ASAP

Hi there, it seems a few users are experiencing this issue so I’ve asked the team to investigate.

2 Likes

@marlowe-shaeffer

Everything is ok with the API!!!

For all the other…

Next time → when a Velo-Master gives you some hints …


… you also should start to follow them and searching for more informations about the given hint.

If i am not right! → give me an NOT working example!

@russian-dima I follow the example in the documentation and the hint above and still receive an undefined :

Error: Ambassador client request failed: HTTP STATUS: -1 RESPONSE: “Failed to fetch” See the httpStatus and response fields for more information.

TypeError: Cannot read properties of undefined (reading ‘contactDetails’)

My code is

    let mbr = currentMember.getMember({fieldsets: ['FULL']})
        .then((member) => {
            user_Email = member.contactDetails.emails;
            fullName = `${member.contactDetails.firstName} ${member.contactDetails.lastName}`;
            loginEmail = member.loginEmail;
            return member;
        })
        .catch((error) => {
            console.error(error);
        });
    

I there a problem with the API call?

@youge This is a bug on our end. The team is working on it, and a fix should hopefully be deployed soon. I’ll let you know as soon as it’s resolved.

1 Like