1
votes

I'm trying to get a user's email address without being the "current user".

var query = new Parse.Query(Parse.User);
query.equalTo("objectId", "8Vv6axJ");  
query.find({
success: function(object) {
var username = object.get("username");
   alert(username);                                       
   }
 });    

Seems that I can't get at it. Docs seem to say I should be able to get at it. Seems to not like the var=username line. Thanks.

LATER EDIT: So, per suggestions, I changed to code to:

var query = new Parse.Query(Parse.User);
query.equalTo("objectId", "cx1ha3YPZj"); 
query.find({
   success: function(results) {
         alert(results.length);       
         for (var i = 0; i < results.length; i++) {
             var username = results[i].get("username");
         }    

results.length is 0 . I know the objectID is correct, copied from Parse Browser.

OK. Here is what I have determined:

It appears that although the Parse Docs say that any user can read User data, the following contradicts that. So, the following ACL from User indicates that only the user can read and write it. If you try to change the ACL in the Parse.User, when you refresh it, it changes it back to original ACL.

{"cx1ha3YPZj":{"read":true,"write":true}}

parse ACL link

Parse.ACL(arg1) Creates a new ACL. If no argument is given, the ACL has no permissions for anyone. If the argument is a Parse.User, the ACL will have read and write permission for only that user.

1
are you getting an error in the console? - Patrick Evans

1 Answers

0
votes

Object is a reserved name in several browsers. That's probably why you get the error. Change object to something else should solve the problem.

Also results will return an array of results like:

var query = new Parse.Query(Parse.User);
query.equalTo("objectId", "8Vv6axJ");  
query.find({
    success: function(results) {
       alert(results.length);       
       for (var i = 0; i < results.length; i++) {
           var username = results[i].get("username");
       }                          
    }
});