1

I am trying to access properties located on the User object for the current user in a cloud code function. The current user is passed to the cloud code function and available at request.user. The Cloud Code is deployed to Heroku using parse-cloud-express.

When the request first arrives, it does not contain the user data other than the id.

So I tried performing a fetch to get the latest data:

Parse.Cloud.define("functionName", function (request, response) {
  request.user.fetch().then(function (user) {
    console.log(util.inspect(user));
  });
});

But it outputs the same data and does not seem to include the User object's properties.

2015-12-15T01:19:08.830880+00:00 app[web.1]: { _objCount: 1, className: '_User', id: 'dKqZMSRgDc' }

I also tried performing a query on the user id, but receive the same result.

var userQuery = new Parse.Query(Parse.User);
userQuery.get(request.user.id).then(function (user) {
  console.log(util.inspect(user));
});

How do I get the properties of the User object?

Brad
  • 181
  • 3
  • 13
  • So just refer to here: [http://stackoverflow.com/questions/26286919/parse-cloud-code-retrieving-a-user-with-objectid?noredirect=1&lq=1](http://stackoverflow.com/questions/26286919/parse-cloud-code-retrieving-a-user-with-objectid?noredirect=1&lq=1) – Paradise Nov 10 '16 at 02:58

1 Answers1

0

The problem was not with getting data for the User object, but the way I was logging it. It seems that the data is not available from the object itself, so the output from util.inspect was correct, but does not include any properties. (I'm guessing the internals of the Parse framework manages this in another way.)

I replaced with console.log(user.toJSON()) and can now see the expected data for the user.

Brad
  • 181
  • 3
  • 13