Akshay Khandelwal
Akshay Khandelwal

Reputation: 1570

Get user from parse in Javascript

I know this question may be asked multiple times but I am not able to get the User object in its entirity. The problem is that the user object returns only the username, email and the phone number properties while I have certain fields added like first name and last name to the user object.

I'd like to know if there's a way to get the user object in its entirity

The object on parse cloud should look like

User: 
{
    "firstname": "firstname",
    "lastname": "lastname",
    "username": "username",
    "email": "[email protected]",
    "phone": "0123456789",
    "type": "admin/super-admin/user"
}

I use following query to get the object

var query = new Parse.Query(Parse.User);
query.equalTo("username", "username"); // Whatever be the username passed by search string
query.find({
    success: function (user) {
        console.log("Success:", user)

    },
    error: function (error) {
        //Show if no user was found to match
    }
});

I get the user object as follows:

user:{
    createdAt:"2014-12-27T07:16:09.826Z"
    email: "[email protected]"
    objectId: "223tch5S6J"
    phone: "0123456789"
    updatedAt: "2014-12-27T07:16:09.826Z"
    username: "username"
}

I do not get the other properties like type, firstname, lastname.

Note: I do not need to get the password which parse does not provide anyways so that's not the problem here.

Upvotes: 1

Views: 1803

Answers (1)

matus
matus

Reputation: 1582

user.attributes should hold all the user attributes saved server side

Upvotes: 3

Related Questions