Support Topics Documentation Slack YouTube Blog

Show user email

i want that after the user will login to the app in the headline it will write the user email
i started in this
function(userEmail){
Backendless.UserService.CurrentUser();
.then (function (userEmail){
var x = document.getElementById(“myP”).innerHTML;
document.getElementById(“demo”).innerHTML = x;
})
};
i know that something is missing in my JS code but don’t know what

Hi @rami_mordechay,

here is working example:

  Backendless.UserService.getCurrentUser()
   .then(function(user) {
     document.getElementById('demo').innerText = user.email
   })

Note that Backendless.UserService.CurrentUser() returns user object, not just userEmail.
Also when using promise functions (like Backendless.UserService.CurrentUser()) you should return it from functions in order to have result in the then callback function.

Regards,
Stanislaw