0
votes

Since I'm kinda new to cloud code, I have the question mentioned above!

1) Do cloud code triggers, beforeSave - afterSave etc, need to call response.success and response.error when they are done?

2) If so, is it possible for the client to receive that response?

Edit: For the first question, I realised that it's necessary for the "before" triggers only... The second question remains unanswered!

1

1 Answers

1
votes

In a beforeSave() trigger, the response.sucess() is returned to the client like this. It's only in case of error that it could be interesting to return a specific message (for a business validation before save for i.e) So in your cloud code you could write :

Parse.Cloud.beforeSave("MyObject", function(request, response) {

  //business validation then if fail :
  response.error("there was an error blabla...");
}
});

Then the Client will receive a Parse Exception with the corresponding message