-
I have searched the entire docs but haven't seen some guides on error handling and I'm facing a bit of an issue with that. What I tried: const { mutate, status, data, error } = login()
const onLogin = () => {
if(!username || !password) return
mutate({username, password})
}
useEffect(() => {
if(status === 'error') {
console.log(error.message)
}
}, [status]) I want to get just the error message printed to the console but the entire error log is been printed instead which is not what I want because I want to display the error message to the user. THANKS IN ADVANCE!! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
react-query logs all errors to the console by default. You can change that with a custom logger: https://react-query.tanstack.com/reference/setLogger |
Beta Was this translation helpful? Give feedback.
-
I archived that by following the error log path to the message. My use-case: if(status === 'error') {
console.log(error.response.errors[0].message)
} |
Beta Was this translation helpful? Give feedback.
I archived that by following the error log path to the message.
My use-case: