Skip to content

TypeError: Request constructor: HEAD or GET Request cannot have a body #174

Answered by jiripudil
petrparolek asked this question in Support
Discussion options

You must be logged in to vote

Hello,

Naja sends the data as a request body which is not supported for GET and HEAD methods – for those, data should be sent as part of the URL in the query string.

I guess nette.ajax.js (or rather the underlying jQuery's $.ajax) puts given data into the query string for you? I think Naja could do the same, especially since it already does so when sending forms via GET 🤔 (edit: 👉 #175)

For the time being, I believe something like this should work:

const url = new URL({link changeYear!});
url.searchParams.append('year', '2020');

naja.makeRequest('GET', url);

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by petrparolek
Comment options

You must be logged in to vote
1 reply
@jiripudil
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Support
Labels
None yet
2 participants