Redirect to a url with current user's email

In the code above, I’m trying (just a test), after login, redirect the user to an url that contains his email.

This page is published in https://www.accumaker.com/apphome.

The code was not indicated as error by wixeditor, but the redirection is not happening.
Someone can help me please?
Thanks in advance!


import wixUsers from ‘wix-users’;
let user = wixUsers.currentUser;

let userId = user.id; // “r5cme-6fem-485j-djre-4844c49”
let isLoggedIn = user.loggedIn; // true

user.getEmail()
.then( (email) => {
let userEmail = email; // “user@something.com
} );

import wixLocation from ‘wix-location’;
$w.onReady(() => {
var parametrounico = wixLocation.url.split(“?”);
var urlpadrao =
https://creator.zohopublic.com/accumakerapp/accumaker-anamnese/page-embed/Home_Postagem/Cvr4TEy2mwa4n0396SFjXEpB8H6bytAAYA43RYMggmXvHUPDSJ7nTKBxk1v8HFPrD107Fa81eH75jS6Zfy4h4782SPrgpm7h68r1”;
wixLocation.to(urlpadrao + “?” + this .userEmail);
});

import wixLocation from ‘wix-location’; should be at the very top of the page code

Then at the bottom of the page code like this…

console.log(" https://creator.zohopublic.com/accumakerapp/accumaker-anamnese/page-embed/Home_Postagem/Cvr4TEy2mwa4n0396SFjXEpB8H6bytAAYA43RYMggmXvHUPDSJ7nTKBxk1v8HFPrD107Fa81eH75jS6Zfy4h4782SPrgpm7h68r1 /" + userEmail);

wixLocation.to (" https://creator.zohopublic.com/accumakerapp/accumaker-anamnese/page-embed/Home_Postagem/Cvr4TEy2mwa4n0396SFjXEpB8H6bytAAYA43RYMggmXvHUPDSJ7nTKBxk1v8HFPrD107Fa81eH75jS6Zfy4h4782SPrgpm7h68r1 /" + userEmail);

Move all your code into the onReady function first. Then you need to move your wixLocation into the .then returned promise user.getMail because you must wait for that to return the Mail and then do the redirect.

nice, it worked now!
thanks!

So is code sending the current user to a dynamic page? and the dynamic page has the URL that includes the current user’s email?