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

fix the example of Fetch_API with body and URLSearchParams #38118

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

NewUserHa
Copy link

Description

fix the example of Fetch_API with body and URLSearchParams and post

Motivation

fix error

Related issues and pull requests

Fixes #38115

@NewUserHa NewUserHa requested a review from a team as a code owner February 12, 2025 01:21
@NewUserHa NewUserHa requested review from sideshowbarker and removed request for a team February 12, 2025 01:21
@github-actions github-actions bot added Content:WebAPI Web API docs size/xs [PR only] 0-5 LoC changed labels Feb 12, 2025
@Josh-Cena
Copy link
Member

@NewUserHa See my comment in the linked issue: this is intended, and none of the other code examples have method: "POST" explicitly. Do you want to update this PR to implement your other suggestion (showing sending the search params as URL instead of body) instead?

@NewUserHa
Copy link
Author

I think if this code block is intended not able to run then it should be marked as a error block like the one below it,
and I hope the documentation can have an example for a practice example for "GET" having multiple query with the same key names because there is no good one after searched

@Josh-Cena
Copy link
Member

Could you update other occurrences of the same issue as well?

@NewUserHa
Copy link
Author

what about just updating the // ... to // ...incompleted code or // ...here need add more codes in this markdown page

@Josh-Cena
Copy link
Member

I think adding method: "POST" doesn't hurt, and makes the example directly copiable, which is desirable.

@NewUserHa
Copy link
Author

agree

@NewUserHa
Copy link
Author

if in future updating the // ... to // ...incompleted code or // ...here need add more codes in this markdown page
can prevent reader from misunderstanding to that "// ..." means "my codes go there"

@Josh-Cena Josh-Cena requested review from wbamberg and removed request for sideshowbarker February 12, 2025 21:34
@Josh-Cena
Copy link
Member

Per the discussion in the issue, we should:

  • Introduce the method option first, then body, then headers; this way when we say "requests with body can only be sent with POST", it doesn't appear confusing or out of context
  • When discussing any fetch call with a body we should explicitly use method

Copy link
Contributor

Preview URLs

Flaws (2)

URL: /en-US/docs/Web/API/Fetch_API/Using_Fetch
Title: Using the Fetch API
Flaw count: 2

  • broken_links:
    • /en-US/docs/Glossary/stringifier is ill cased
  • macros:
    • Macro produces link /en-US/docs/Glossary/stringifier which is a redirect

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:WebAPI Web API docs size/xs [PR only] 0-5 LoC changed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

example of Fetch_API with body and URLSearchParams is invalid in both browser chrome and nodejs
2 participants