我无法将当前用户传递给Parse.User.currentAsync()。then(function(user)){}

时间:2019-07-22 23:09:10

标签: javascript react-native parse-platform

我想让当前用户可以在Parse.User.currentAsync()之外的公共场所使用。然后(函数(用户)当前用户未定义,如何将其传递给变量??

 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) { ....

1 个答案:

答案 0 :(得分:0)

const user = await Parse.User.currentAsync();
alert(user.getUsername());