I used the code below in order to get the user logged in email
the id is fine
can not get the email:
in preview mode:
Please help!
I used the code below in order to get the user logged in email
the id is fine
can not get the email:
in preview mode:
Hi,
Your code has two problems:
let userEmail is defined inside the .then() handler and its context is not available outside of the .then() handler.
The line of code $w(“#text17”).text = email; is directly after the Promise, but unfortunately is executed before the Promise has been fulfilled. This is why " userEmail is not defined ".
You need to set the text field after the Promise has bee fulfilled - that is, inside of the .then() handler. Like this:
user.getEmail()
.then( (email) => {
$w("#text17").text = email;
}
See the forum post Promises, Promises for a gentle explanation of Promises.
I hope this helps.
Yisrael
Thanks! You made my day … or even better, my night!