Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON or URL Encoded #4

Open
ricardoalcocer opened this issue Sep 14, 2018 · 2 comments
Open

JSON or URL Encoded #4

ricardoalcocer opened this issue Sep 14, 2018 · 2 comments

Comments

@ricardoalcocer
Copy link

$data = json_decode(file_get_contents("php://input"));

Hey. I'm playing with this code and for me on my local MAMP environment and using INSOMNIA REST client, I get the data as a query string instead of JSON. Insomnia is set to POST and send the data as Form URL Encoded.

I have no preference of one or the other, but do you know what's triggering the difference in output formats?

@ricardoalcocer
Copy link
Author

I'm probably answering my own question here, but is it because you're sending it as JSON in the first place here?

return JSON.stringify(myJson);

If so, what's the best practice when it comes to grab that data from the request? Shall I assume JSON?

@MaxwellEnemuo
Copy link
Contributor

Yes. When using a REST client simply POST data as JSON because that's what the end point expects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants