1
votes

I have a backend on Parse.com. I am trying to get a value from a User object in javascript cloud code, but it is not working. Let's say I am trying to get the email.

Here is the cloud code that retrieves a User Object...

var printUser = function(){

var query = new Parse.Query(Parse.User);
query.get( "2FSYI1hoJ8");  
query.find({
  success: function(result) {

    console.log(result);
  }
});
};

and here is the result of that search...

I2014-03-07T22:43:21.894Z] [{"email":"[email protected]","phoneVerified":true,"randomNumber":99862,"toPhone":"+13035551212","username":"a","objectId":"2FSYI1hoJ8","createdAt":"2014-03-02T21:07:02.192Z","updatedAt":"2014-03-07T22:43:13.103Z","__type":"Object","className":"_User"}]

So I know the search works. I tried using 'result.get("email")', 'result.email', 'result("email")' and any variation I could find in their documentation to get the email value, but nothing works.

The error codes vary based on what is being called, so I will spare you that.

What am I missing?

1

1 Answers

2
votes

You have an array of objects (with only one element), not a standalone object. The first element in your array is your result object:

result[0].email

will get you the email property of that object.