Skip to content

Handling errors in fetch #23

@FarahZaqout

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.

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