user.getEmail() not working in Preview Mode

Is anyone else having this weird issue? It just started today. When using the standard user.getEmail() call, it throws a fetch error when I am testing my code in preview mode. It used to work, but now I get this Fetch error. In Live mode, it works fine. I tested this with a couple of sites that I am working on that is live and both work, but when I go into editor and then preview mode, it fails with just the error: Fetch error.

Has anyone else experience something similar? It breaks in preview, but works in live?

One other note, all my other standard function calls seem to work fine. I just cannot get the user.getEmail to work. works fine, my calls to the server side work fine, as well as all other pieces of code. I just can’t get this one call to work, all of a sudden.

If you run this what error do you get, the same fetch error?

  .then( (email) => {
    let userEmail = email;
  } );

There is also one thing to be aware of, members / users stuff are not well working in Preview mode at all I think and recommend you to test the same page in published mode to see if you get the same error.

1 Like

Hi Andreas,

I am using the code above, just like that. So, that’s why I am posting to see if anyone else has had a similar issue. I opened a support ticket with Wix and they told me it’s custom code and they don’t deal with these and referred me to the community forum. Honestly, is this custom code? No. It’s Wix’s standard code that they document and use.

Here’s the actual error from console.log: TypeError: Failed to fetch

Sio, just for kicks, I went back onto my live site and everything works fine. I go into preview mode for the same page using the same email and I get the above error. Like i said, it only seems to fail in preview mode and just this one function call. It’s really odd, since it’s been working all this time (for a few months while I’ve been building out my site).

Hi @pl993 !

Please take a look at the documentation from the API :

Therefor checking some methods in the published site only is completely acceptable and expected.

Let me know if something actually breaks in your site.


1 Like

Hi Doron,

Thanks. I guess I will live with this quirk. Odd that the user.getEmail() function which was working for me in preview mode for the past four months would just stop working all of a sudden. I did see the note that not all functions will work in preview mode, but I didn’t think that a feature would work and then stop working. It would be one thing if user.getEmail() never worked in preview mode (like giving candy to a kid and taking it away).

Anyways, I have just hardcoded my user email to allow me to test in preview mode and as I said in my previous replies, it works fine in live mode…

Well, I’ll make sure to forward it to our QA team.
Thank you for bringing it to our attention!


Hey guys i am experiencing this issue too for one of my clients
So i have to use export function so that i can make the code to work

I have attached the image which shows the error
I can’t able to use getEmail and redirect the user after save using dataset setting

This is the code i have on the site
Working for on live site but not on preview mode

// For full API documentation, including code examples, visit
import wixUsers from 'wix-users';
import wixLocation from 'wix-location';

let user = wixUsers.currentUser;
var email;
$w.onReady(async function () {
    email = await user.getEmail();

export function button1_click(event) {
    $w('#dataset1').setFieldValue('user', email);

export function dataset1_afterSave() {

export function dataset1_error() {

I think this is a “bug”

Hello. Thank you for bringing this into light. I’ve already opened a ticket about this bug for our development team to resolve. Although, I must admit - we can’t promise a quick fix here, since the main flow on a live site is working fine.

Once again, thanks for being attentive.
Kind regards, Alex

1 Like

Hi Aleksander, thanks for opening up a bug for this. Hopefully, it will get resolved soon? I’m glad I wasn’t the only one thinking there is something wrong with a standard (core) function.

Thanks Alex!

hi guys…i am a noob…and wondering if this is still a problem

you can imagine how frustrating it is for a noob…i am using the code below and not sure if its me or the system now.

import wixUsers from ‘wix-users’;

import wixData from ‘wix-data’;

import wixLocation from ‘wix-location’;

$w.onReady( function () {

let user = wixUsers.currentUser;

let isLoggedIn = user.loggedIn; // true


.then( (email) => { 

let userEmail = email;

$w("#emailtext").value = userEmail; 
$w("#text8").text = userEmail 

} );

$w(“#button1”).onClick( (event) => {

$w(“#text8”).text = ‘please work’;

} );


just came across this on my site that has been working absolutely fine for 14 months, now today in preview… boom - won’t get email

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!