Can not get Email of current User

I use the right code, but i can’t get current user email. When i run in preview mode, console log display the email as undefined. Please help me !!

Put the console.log inside the “then” block

I tried it. But it seem getEmail() is not working.

Or just like this, it’s same:

I have this same problem - its been killing me trying to work it out!

@handsonguitarstore , I don’t know. But I think that you used the wrong collection name, it should be “Members/PrivateMembersData”.
(that’s not the reason for your issue, but it can be another issue).

Wix Users API does not function properly in the Preview mode.

Please test it on the Live site

Oh my god, it’s true, tks you. It’s such a inconvenience for test. WIX need to fix it soon :frowning:

hey guys, so after getting nowhere with the comments on multiple pages, I drank a few pints and looked at the new documentation; This works for me

import { currentMember } from ‘wix-members’ ;

currentMember . getMember ()
. then (( member ) => {
const Email = member . loginEmail ;
$w ( ‘#dataset1’ ). setFieldValue ( ‘userEmail’ , Email );
console . log ( Email );
return member ;})

Hope it helps, it also works in preview!