wixlocation. to does not redirect to internal page

Hello. For a while now i am stuck to this. I want page redirect to diffrient page after user has logged in, but it is not working

import wixLocation from ‘wix-location’ ;
import wixUsers from ‘wix-users’ ;

let user = wixUsers.currentUser;
let userId = user.id;

$w.onReady( function () {
})
if ($w(wixUsers.currentUser.loggedIn)) {
$w( wixLocation.to( “/anketa-from-beginning” ));
}
else {
$w(wixUsers.promptLogin());
}

1 Like

The code should be placed within the onReady handler:

$w.onReady(function () {
if ($w(wixUsers.currentUser.loggedIn))
{
$w( wixLocation.to(;}) ";}) /a;}) nketa-from-beginning";}) ));;})
}
else {
$w(wixUsers.promptLogin());
}
})