Reputation: 3
A parse server cloud function is defined via
Parse.Cloud.define("hello", function(request, response) {..});
on the response, I can call response.success(X)
and response.error(Y)
, and that sets the http response code and the body of the response.
But how do I define a different code, like created (201)? And how do I set the headers of the response?
thanks, Tim
Upvotes: 0
Views: 1218
Reputation: 4378
You are allowed to return any valid JSON from response.success()
. Therefore, you could create an object with fields such as code
, message
, and value
, so you can set the code, give it a string descriptor, and pass back the value you normally would, if there is one. This seems to accomplish what you need, though you will have to keep track of those codes across your platforms. I recommend looking up standard http response codes and make sure you don't overlap with any standards.
Upvotes: -1