-
Notifications
You must be signed in to change notification settings - Fork 326
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
Reject Promise on Error Response #627
Comments
I realize this is a dupe of #18. After reading the entire discussion there, I think it would make sense to revisit this issue since there are still developers for whom this is counter-intuitive all these years later – exception/error semantics aside, this is a relatively high-level abstraction and as such, |
We cannot change the behavior at this point, that would break backwards compatibility. I also don't think we want to. Note that you can use (It also seems you didn't finish your sentence in the previous comment, but I'll point out that |
Ah, my comment submitted before I finished it. Sorry about that! @annevk, everything you’ve said makes a lot of sense. Is there a possibility to add warnings (with detailed instructions) on server errors and how to handle them to the spec in order to better instruct newer developers? |
@TejasQ by server error do you mean HTTP status codes? Those are documented in HTTP upon which Fetch is layered: https://tools.ietf.org/html/rfc7231#section-6. |
@annevk right – I see. To clarify, I meant: in the event the
in order to make coding with |
More documentation is planned, see #543. Help with that is appreciated. As for surfacing warnings, I think that would be up to those making the developer tools and best directly asked of them. It might be perceived as spammy as there are many legitimate reasons to get non-2xx statuses. |
Great. Thanks! Happy to close this. |
The Issue
I find working with this API fairly different to reason about when calling
fetch
and receiving an error response from an external resource. Currently, I am implementing a feature that has the following flow:fetch
a resource withGET
fetch
call withPOST
Currently, if the GET fails with a
404
, the promise is not rejected and I am unable to handle the error appropriately (by creating what does not already exist).Proposed Change
The API that I (and others on my team) imagine and would typically expect to work with is as follows:
If this issue makes sense and is considered, I'm happy to help describe, implement or test to the best of my ability.
cc @Angarsk8 as a fellow coder with this issue.
The text was updated successfully, but these errors were encountered: