redux-query icon indicating copy to clipboard operation
redux-query copied to clipboard

Handling errors

Open pgross41 opened this issue 3 years ago • 1 comments

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?

pgross41 avatar Jul 23 '22 05:07 pgross41

There is some ability to track errors via the Error State this would require you to add this to your redux store

vuamp avatar Sep 13 '23 01:09 vuamp