How to follow user link in cloud code?

In the function after the CloudSave cloud code:

Parse.Cloud.afterSave("Post", function (request) { var post = request.object; if (post.has('author')) { var author = post.get('author'); // author is a Link to a specific Parse.User } } 

I am trying to get the Parse user email that the Post author field points to.

In the above example, author ends up containing:

 { "__type":"Pointer", "className":"_User", "objectId":"413wgL9vf1" } 

Essentially, I want to read the email property of the user that the pointer points to.

I tried to do author.get('email') and it failed by saying "undefined". Email is installed in the database.

What is the right way to do this? Should I write a query regarding the User class using the objectId from the link, or is there an easier way?

+5
source share
1 answer

Turns off all I need is author.fetch().then(...) .

0
source

Source: https://habr.com/ru/post/1259794/


All Articles