parse-server icon indicating copy to clipboard operation
parse-server copied to clipboard

Can't access request params

Open mikepaggi opened this issue 10 years ago • 8 comments

I can't seem to access the request params as it appears to be displaying as undefined.

I'm posting to a cloud function with populating a parameter of "q".

I post to this URL and just have it print the request.params.q as part of the json response. I've tried with my personal project and also the parse-server-example and i get the same issue. (the url below is actually to the parse-server-example)

http://localhost:1337/parse/functions/hello?q=test

Is this an error due to Parse Server (though it's express.js middleware and just passing existing request and response) or am i doing this wrong? I can't find help through stack overflow so i'm coming here...

mikepaggi avatar Feb 12 '16 00:02 mikepaggi

Have you tried posting your params in the request body instead of the url?

drew-gross avatar Feb 12 '16 06:02 drew-gross

No I have not. What would it look like In terms of how I'm sending it?

Also this used to work when it was on Parse.com before (sorry should of mentioned that) so I'm not sure why it stopped working.

mikepaggi avatar Feb 12 '16 17:02 mikepaggi

Also looking on the example on the page listed below it looks like I should be able to access the request.params json object

https://parse.com/docs/cloudcode/guide#cloud-code-cloud-functions

mikepaggi avatar Feb 12 '16 17:02 mikepaggi

You can see some example CURLs in our REST guide that use a body in a POST request: https://parse.com/docs/rest/guide#cloud-code however if this used to work in parse.com then it's a bug and we should fix it.

drew-gross avatar Feb 12 '16 18:02 drew-gross

I will give that a try for at least the moment but yes it used to work.

Also in the parse documentation on that same page you will see the following.

In general, two arguments will be passed into cloud functions:

request - The request object contains information about the request. The following fields are set: params - The parameters object sent to the function by the client. user - The Parse.User that is making the request. This will not be set if there was no logged-in user.

mikepaggi avatar Feb 13 '16 00:02 mikepaggi

posting to the body like that seemed to work for now at least thank you. At least some point it would be good to fix this but seems like i can just use this now for at least testing purposes when I use postman.

mikepaggi avatar Feb 13 '16 00:02 mikepaggi

@drew-gross I'll take up that one. Can you assign to me?

flovilmart avatar Feb 15 '16 23:02 flovilmart

Merged in #439 which should fix this, will release it as 2.0.9.

gfosco avatar Feb 16 '16 13:02 gfosco