-
Notifications
You must be signed in to change notification settings - Fork 22.6k
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
example of Fetch_API
with body
and URLSearchParams
is invalid in both browser chrome and nodejs
#38115
Comments
I missed the |
what about also adding a new example for |
Oh actually, I reread this section, and what we are showing now is intended. This is not a complete code example that you can just copy and run; it only shows the parts relevant to our discussion. A complete POST request example is shown as late as https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch#making_post_requests |
but this code block is not marked as red(error) status like the one below it |
It's not intending to show "bad code". The |
that |
I agree with you that it's hard to read. Shall we update all examples containing a body to use method: "POST"? There are many on this page. |
the API references pages are good to read, these other pages are like tutories and usually too long to read for quick reference, it should be better to at least have good practice examples |
This would take some careful rework IMO. The idea of this part of the guide is that it introduces three options, one at a time. It's not intentional that you can make a complete request at each stage. Then it shows how to combine them to make a complete POST request. So if it's minimally changed to make a complete POST request at the point the body is introduced, then the next bit is incoherent. |
Shall we introduce the method first, then, since we talk about methods when we introduce the body option anyway? |
We do already introduce the method first. We could delete Making POST requests, and effectively cover it earlier, so:
I guess I'm a bit sensitive about this page because I spent some time turning it from a morass of random facts about fetch into something organized, and I don't want it to go down that route again. |
Yes, I think that would be a more reasonable order. |
MDN URL
https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch
What specific section or headline is this issue about?
No response
What information was incorrect, unhelpful, or incomplete?
copy from the documention:
this code doesn't work in both browser chrome and nodejs, and both throw error "Uncaught TypeError TypeError: Failed to execute 'fetch' on 'Window': Request with GET/HEAD method cannot have body."
What did you expect to see?
it works
Do you have any supporting links, references, or citations?
No response
Do you have anything more you want to share?
No response
MDN metadata
Page report details
en-us/web/api/fetch_api/using_fetch
The text was updated successfully, but these errors were encountered: