0

I want to get the current user to use in public but outside the Parse.User.currentAsync().then(function(user) current user is undefined, How can I pass it to a variable ??

 var userName;
 Parse.User.currentAsync().then(function(user) {
           userName =  user.get('username')  

   });

 alert(userName) //undefined

 ......

 user.equalTo("username", userName); //userName is undefined
 user.find().then(results => {

  for(const result of results) { ....
Azerilla
  • 3
  • 2

1 Answers1

0
const user = await Parse.User.currentAsync();
alert(user.getUsername());
Davi Macêdo
  • 2,954
  • 1
  • 8
  • 11