I wrote this code but I don’t understand why when I click on the buttonProfile button it takes me to a 404 error page at this link:
https://bigimatt14.wixsite.com/ilmiosito-2/recruiters/profile/${wixUsers.currentUsers.id}
is it a code error or is there anything else?
This is the page code
import wixUsers from 'wix-users';
import wixData from 'wix-data';
import wixLocation from 'wix-location';
$w.onReady(function () {
setTimeout(loginCheck, 500); // timeout per far in modo che l'importazione avvenga totalmente
});
function loginCheck () {
if (wixUsers.currentUser.loggedIn) {
$w('#buttonLogin').label = 'Logout';
$w('#buttonProfile').enable();
}
else {
$w('#buttonLogin').label = 'Login/Sign-up';
$w('#buttonProfile').disable();
$w('#buttonPost').disable();
}
}
export function buttonLogin_click(event) {
// fai questo se l'utente è loggato
if (wixUsers.currentUser.loggedIn) {
wixUsers.logout()
.then(() => {
//disable profile and post job buttonLogin
loginCheck();
});
}
else{
let userId;
let userEmail;
// richiesta di login
wixUsers.promptLogin( {'mode': 'login'})
.then((user) => {
userId = user.id;
return user.getEmail();
})
.then((email) => {
// controlla se la mail esiste già nel database, sta facendo la stessa cosa che fanno i filtri dataset
userEmail = email;
return wixData.query('Recruiters')
.eq('_id', userId)
.find();
})
.then((results) => {
// tutto questo per aggiungere dati al database
if (results.items.length === 0) {
let randVar = Math.floor(Math.random()*8999 ) +1000;
// crea oggetti da aggiungere al database
const toInsert = {
'_id' : userId,
'email' : userEmail,
'verified': 'pending',
'randomNumber': randVar
}
// aggiunge i dati al database
wixData.insert('Recruiters', toInsert)
//questo si attiva se qualcosa va storto e ti riporta l'errore
.catch((err) =>{
console.log(err);
});
}
setTimeout(loginCheck, 500)
})
.catch((err) =>{
console.log(err);
});
}
}
export function buttonProfile_click(event) {
wixLocation.to('https://bigimatt14.wixsite.com/ilmiosito-2/recruiters/profile/${wixUsers.currentUsers.id}'); // apostrofo inverso =Alt 96 /recruiters/profile/${wixUsers.currentUsers.id}
}