When I’m testing my site using different accounts, I can’t open up the profile page that I coded for my site members. Instead, this message pops up: “there’s nothing here… we can’t find the page you’re looking for. Check the URL, or head back home.” The profile pages were working perfectly up until now, and I really need to fix this.
Here is a copy of my code, just in case you see anything wrong:
import wixUsers from ‘wix-users’;
import wixData from ‘wix-data’;
import wixLocation from ‘wix-location’;
$w.onReady( () => {
if(wixUsers.currentUser.loggedIn) {
$w(“#button13”).label = “Logout”;
$w(“#button12”).show();
}
else {
$w(“#button13”).label = “Login”;
$w(“#button12”).hide();
}
} );
export function button13_onclick() {
// user is logged in
if(wixUsers.currentUser.loggedIn) {
// log the user out
wixUsers.logout()
.then( () => {
// update buttons accordingly
$w(“#button13”).label = “Login”;
$w(“#button12”).hide();
} );
}
// user is logged out
else {
let userId;
let userEmail;
// prompt the user to log in
wixUsers.promptLogin( {"mode": "login"} )
.then( (user) => {
userId = user.id;
return user.getEmail();
} )
.then( (email) => {
// check if there is an item for the user in the collection
userEmail = email;
return wixData.query("Profile")
.eq("_id", userId)
.find();
} )
.then( (results) => {
// if an item for the user is not found
if (results.items.length === 0) {
// create an item
const toInsert = {
"_id": userId,
"email": userEmail
};
// add the item to the collection
wixData.insert("Profile", toInsert)
.catch( (err) => {
console.log(err);
} );
}
// update buttons accordingly
$w("#button13").label = "Logout";
$w("#button12").show();
} )
.catch( (err) => {
console.log(err);
} );
}
}
export function button12_onclick() {
wixLocation.to(/Profile/Update/${wixUsers.currentUser.id}
);
}
Thanks in advance to anyone who helps out!