Parse.com cloud code GET function with parameters?
I am writing a cloud code function in parsing and I am trying to figure out how to handle parameters in a GET url.
So I have a simple function:
Parse.Cloud.define("someFunction", function(request, response) {
// how can I use GET parameters here??
});
How to rename "someFunction"
to handle GET parameters so that I can use them in cloud code function logic?
so for example i want to be able to pass the name string: "myName"
to GET
https://api.parse.com/1/functions/someFunction name = myName
Any simple example? I've been looking for a while when I couldn't find it.
thank
EDIT: So I changed my function to look like this:
Parse.Cloud.define("someFunction", function(request, response) {
// how can I use GET parameters here??
var name = request.params.name
response.success("the name = " + name)
});
then I call it like this: https://api.parse.com/1/functions/someFunction?name=someName
I'll be back:
{"result":"the name = **undefined**"}
source to share
Cloud functions are called with a POST request, not a GET request. Here is a simple example for cURL, taken from the documentation [1].
curl -X POST \
-H "X-Parse-Application-Id: YOUR_APP_ID" \
-H "X-Parse-REST-API-Key: YOUR_REST_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name":"John Doe"}' \
https://api.parse.com/1/functions/someFunction
source to share