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?
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.
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.