-
Notifications
You must be signed in to change notification settings - Fork 23k
Clarify fetch() error handling behavior for Response #42497
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
Conversation
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.
Corrected spacing and formatting issues in the response documentation.
wbamberg
left a comment
There was a problem hiding this 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.
|
Thanks for the suggestion! I’ve updated the example to explicitly handle HTTP error cases using |
|
Preview URLs (comment last updated: 2025-12-23 04:31:19) |
wbamberg
left a comment
There was a problem hiding this 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.
wbamberg
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 thank you
…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)
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.