Skip to content

Handling errors in fetch #23

Description

@FarahZaqout

.catch(() => {

The .catch() method in your fetch will not be able to handle a 4xx or 5xx response from the server.

This is handled in the .then() method.

.then((res) => {
   if (res.status === 500) // handle server error here
   if (res.status === 400) // handle bad request error here
})

the catch in fetch will only see a network error.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions