Skip to content

Conversation

@Akarsh-Kiran-Gowda
Copy link
Contributor

This PR adds a small clarification note explaining that fetch() only
rejects on network errors and that HTTP error responses should be
handled using Response.ok or Response.status.

Add a short note explaining that fetch() only rejects on network errors
and that HTTP error responses should be handled using Response.ok
or Response.status.
@Akarsh-Kiran-Gowda Akarsh-Kiran-Gowda requested a review from a team as a code owner December 22, 2025 14:28
@Akarsh-Kiran-Gowda Akarsh-Kiran-Gowda requested review from wbamberg and removed request for a team December 22, 2025 14:28
@github-actions github-actions bot added Content:WebAPI Web API docs size/s [PR only] 6-50 LoC changed labels Dec 22, 2025
@github-actions github-actions bot added size/xs [PR only] 0-5 LoC changed and removed size/s [PR only] 6-50 LoC changed labels Dec 22, 2025
Copy link
Collaborator

@wbamberg wbamberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your PR!

It would be better to update the example to handle this error case. Note that both the basic example in the fetch() page and the first example in the Using the Fetch API do this properly.

Added error handling for fetch response in example code.
@github-actions github-actions bot added size/s [PR only] 6-50 LoC changed and removed size/xs [PR only] 0-5 LoC changed labels Dec 23, 2025
@Akarsh-Kiran-Gowda
Copy link
Contributor Author

Thanks for the suggestion! I’ve updated the example to explicitly handle HTTP error cases using response.ok, following the pattern used in the fetch() and Using the Fetch API pages. Please let me know if this looks good.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 23, 2025

Preview URLs

(comment last updated: 2025-12-23 04:31:19)

Copy link
Collaborator

@wbamberg wbamberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, the code sample looks good to me. Just had a comment on the note.

Removed note about fetch promise rejection behavior.
Copy link
Collaborator

@wbamberg wbamberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 thank you

@wbamberg wbamberg merged commit 252040e into mdn:main Dec 23, 2025
7 checks passed
wbamberg added a commit to wbamberg/content that referenced this pull request Dec 24, 2025
…skeys-guide

* origin/add-passkeys-guide:
  Clarify fetch() error handling behavior for Response (mdn#42497)
  Add code example to Closure glossary entry (mdn#42477)
  42252 add new relative units ff release (mdn#42470)
  Remove duplicated word (mdn#42496)
  42252 add new relative units (mdn#42469)
  TrustedTypes: Range.createContextualFragment() (mdn#42493)
  Fix CSS, HTML, and HTTP landing pages to match sidebar content and order (mdn#42460)
  TT: CSP trusted types/require-trusted... fixes (mdn#42461)
  Improve console output formatting in Recursion glossary (mdn#42478)
  Add Sec-CH-Width + consistency fixes (mdn#42453)
  webextensions/manifest.json/options_page: typo (mdn#42394)
  webextensions/api/tabs/onupdated: Fix section link (mdn#42393)
  fix: add missing closing parenthesis (mdn#42482)
  docs: mark srcData as required in bufferSubData (mdn#42483)
  docs(learn): remove invalid type attribute from video example (mdn#42479)
  Drop 'read-only' from role (mdn#42474)
  Fix: Update bufferSubData parameters to match WebGL 1 spec mdn#42315 (mdn#42411)
  chore: Replace links with `cssxref` macro in the learn area (mdn#42446)
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/s [PR only] 6-50 LoC changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants