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

The Example for Form URL Encode and JSON is lost for request. New JS programmer that want to see the example can't find one #14858

Open
benyaminl opened this issue Apr 10, 2022 · 1 comment

Comments

@benyaminl
Copy link

benyaminl commented Apr 10, 2022

MDN URL

https://developer.mozilla.org/en-US/docs/Web/API/fetch

What specific section or headline is this issue about?

fetch example for form url encode and json body request

What information was incorrect, unhelpful, or incomplete?

Take example, we need to send data to server using body param like using forms or even json to server, in the past this example is there, and provided, but after mdn remake it's gone

eg

end point : contact.php
body : name=foo&email=bar&message=hello Mozilla

should be in example :

fetch("contact.php", {
    method: "POST"
    body: new URLSearchParams({
        name: "foo",
        email: "bar",
        message: "Hello Mozillaaaaaaaaaaa"
    })
})
.then((r) => r.text())
.then((d) => {
console.log(d)
});

or if in JSON we can change it into

fetch("contact.php", {
    method: "POST"
    body: JSON.stringify({
        name: "foo",
        email: "bar",
        message: "Hello Mozillaaaaaaaaaaa"
    })
})
.then((r) => r.text())
.then((d) => {
console.log(d)
});

What did you expect to see?

Some example for request like for JSON, for URL Encoded/search params and docs regarding it.

Do you have any supporting links, references, or citations?

It's been there for long time, and poof vanish!

Proof : https://stackoverflow.com/a/53189376/4906348

Do you have anything more you want to share?

If allowed, I will add the draft into the docs.

MDN metadata

Page report details
@github-actions github-actions bot added the needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. label Apr 10, 2022
@sideshowbarker sideshowbarker added Content:WebAPI Web API docs and removed needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. labels Apr 11, 2022
@sideshowbarker
Copy link
Collaborator

If allowed, I will add the draft into the docs.

Yes, please write up a PR

benyaminl added a commit to benyaminl/content that referenced this issue Apr 12, 2022
Adding some improvement to example, and linking to other section that has the example. 
Related to mdn#14858 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment