Skip to content

Handling errors #280

@pgross41

Description

@pgross41

Is there an easier way to handle errors? The best I can see is to manually safely check the status:

const [ queryState ] = useRequest(queryConfig);
if(queryState?.status && queryState?.status >= 400) {
    alert('error')
}

It would be nice if a boolean was provided:

const [ queryState ] = useRequest(queryConfig);
if(queryState.failed) {
    alert('error')
}

The definition of failed could default to >=400 or provide a custom callback in the config (similar to axios validateStatus). Is there a better option I'm not seeing that's already available?

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