I am trying to get the currently logged in users email and insert it into some text. This is my code:
import wixData from ‘wix-data’;
import wixUsers from ‘wix-users’;
$w.onReady(() => {
let user = wixUsers.currentUser;
user.getEmail()
.then((email) => {
$w(‘#text24’).text = email
} );
the email doesnt show up and I get an error in console Uncaught (in promise) TypeError: Failed to fetch.
does anyone see my type error? because I cannot. Thank you.
2 Likes
Please post the editor URL of your site. Only authorized Wix personnel can get access to your site in the editor. Please include the name of the page involved.
Please include me in on the resolution because I am having a similar issue on my site for some important functionality.
Please include me as well. I am getting the same error.
code I made work. let me know if you have any questions.
import wixUsers from ‘wix-users’;
import wixData from ‘wix-data’;
import wixLocation from ‘wix-location’;
$w.onReady( function () {
$w(“#dataset1”).onReady( () => {
wixUsers.currentUser.getEmail()
.then((email) => {
$w("#dataset1").setFilter(wixData.filter()
.eq("email", email)
)
.then( () => {
$w("#table1").onRowSelect( (event) => {
let rowData = event.rowData;
wixLocation.to(“/about-us”)
} );
})
. **catch** ( (err) => {
console.log(err);
});
});
});
});