Skip to content

Responses from createHandler in express are not returned #75

Answered by enisdenjo
mjmahone asked this question in Q&A
Discussion options

You must be logged in to vote

If you append the flag -i to the curl request to check the headers you'll get:

$ curl http://localhost:4000/graphql2 --data-urlencode "query=query Q { hello }" -i

HTTP/1.1 415 Unsupported Media Type
X-Powered-By: Express
Date: Mon, 10 Apr 2023 07:49:22 GMT
Connection: keep-alive
Keep-Alive: timeout=5
Transfer-Encoding: chunked

This is because POST with application/x-www-form-urlencoded body is not supported. Only with GET.

To have curl encode the data to the URL, you have to add the -G flag.

$ curl http://localhost:4000/graphql2 --data-urlencode "query=query Q { hello }" -G

{"data":{"hello":"hello"}}

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by enisdenjo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #74 on April 10, 2023 07:48.