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. user.id 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.
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.
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).
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…
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 http://wix.to/94BuAAs
import wixUsers from 'wix-users';
import wixLocation from 'wix-location';
let user = wixUsers.currentUser;
console.log(user);
var email;
$w.onReady(async function () {
email = await user.getEmail();
});
export function button1_click(event) {
$w('#dataset1').setFieldValue('user', email);
$w('#button1').hide();
$w('#text30').show();
$w('#image3').show();
}
export function dataset1_afterSave() {
$w('#button1').show();
$w('#text30').hide();
$w('#image3').hide();
wixLocation.to('/account/Results');
}
export function dataset1_error() {
$w('#button1').show();
$w('#text30').hide();
$w('#image3').hide();
}
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
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.