Then after promptLogin not working

Hey there, I’d like your opinion on this issue, basically whatever i puth in then() is just ignored

$item("#bookButton").onClick(event => {
                    $item("#bookButton").disable();
                    $item("#bookButton").label = "a moment...";
                     if (!isLoggedIn) {
                        wixUsers.promptLogin().then(() => {
                                console.log('then reloading');
                                wixLocation.to(wixLocation.url);
                            });
                    } else {
                            bookButtonClick(itemData, distance)
                    }
                });

I don’t see the message in console
here’s the page https://www.ottostudio.it/allenati
my issue or wix’s issue?

I took a look at your site and you have numerous syntax, logic, and semantic errors in your code. You will first need to clean up the errors before you can expect your code to work as expected.

As an example, the variable isLoggedIn is defined at the top of your code. You have the following lines:

let user = wixUsers.currentUser;
let isLoggedIn = user.loggedIn;

One problem (of many), is that the variable isLoggedIn is undefined. The above lines won’t function correctly where you have them since, as the wix-users documentation states:
The APIs in wix-users can only be used once the page has loaded. Therefore, you must use them in code that is contained in or is called from the onReady() event handler or any element event handler.

Refer to the Corvid API for information you will need to fix the errors.