hachyderm.io is one of the many independent Mastodon servers you can use to participate in the fediverse.
Hachyderm is a safe space, LGBTQIA+ and BLM, primarily comprised of tech industry professionals world wide. Note that many non-user account types have restrictions - please see our About page.

Administered by:

Server stats:

9.5K
active users

Anne van Kesteren

Would you use response.throwIfNotOk()? Or is branching on response.ok sufficient?

@annevk I don’t think I would. I remember fetch throwing, but not on >= 400, being a bit confusing on first encounter, but I don’t think explicitly requesting an exception solves that. I could see myself maybe using a throwOnErrorResponse parameter to fetch (so there would be a single exception to catch), but not if I already had a Response object.

@holst with async/await and try/catch there would be almost no difference between those two options. We have something similar for abort signals.