Hi! I have a custom profile page in my website, and I want to display members’ info on it. One of my steps in doing that is getting the login email of the currently logged in member. I’m using the currentMember API and the getMember() method, and then logging the result to the console (this is for testing and to illustrate). However, after I log in and am redirected to the profile page, it says that the member is undefined. But after I reload the page, it gives the correct info. Why is this happening? I’m also getting this error:
And I’m wondering if it could have something to do with it. I was thinking that since the error says the URL was preloaded, it might have loaded before I logged in, and thus the current member would naturally be undefined. Here is the code I used to display the member to the console:
import { currentMember } from 'wix-members';
$w.onReady(function () {
currentMember.getMember()
.then((member) => {
console.log(member);
});
}
Any and all help is appreciated. Thanks in advance!!