Corvid sign code!!!

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}

}

1 Like

Try wrapping your url string in backticks instead of quotes ’ ’ .

iI would change it to be like this instead. please note that I just did this on my phone so could have missed something :)! let me know if works!

export function buttonProfile_click(event) {
wixLocation.to(”https://bigimatt14.wixsite.com/ilmiosito-2/recruiters/profile/“+wixUsers.currentUser.id);

}

it doesn’t work :frowning:

I tried with the reverse apostrophe but it doesn’t work

Oh! Try quotes instead of “ and it should work :)!

See this article about template literals to see how to use your original code.

See this Stackoverflow thread on where to find the backtick on your keyboard. If you’ve got a PC, then just do a similar search.

what kind of quotes?
I have already tried these types and they don’t work, are there others?

""    ''    ``

Plus, if you look at the original tutorial page for own members profile where the code comes from originally and you have adapted it for your site.
https://support.wix.com/en/article/corvid-tutorial-building-your-own-members-area

You will see there how to write the Wix location to. function with the backticks as David had originally stated along with how to add correctly the additional extra for going to the currently logged in user through their own user ID and not how you have it currently.

export function profileButton_click (event) {
wixLocation.to(/Members/${wixUsers.currentUser.id});
}

GOS thank you very much!!! i solved!

Thank you so much for this! I was having the exact same issue and have been wracking my brain all day trying to figure out what was wrong with my code. :heart: