Handling Error
When i make a request, when api fails i dont receive the api payload from the api that has been sent.
Here is the mutation fn
but in error i get
Request failed with status code 400
this but i want the payload that has been sent from the api... what to do and can someone point me to right direction how to utilize if api sent status code like 400, 500, how to handle error in those situation in react query4 Replies
conscious-sapphire•2y ago
check if error is an instance of AxioError and then grab the response body
xenial-blackOP•2y ago
so i have to use try and catch in mutation function itself and get the body and throw the body with in it
conscious-sapphire•2y ago
you can do that, or check the error in the component, that's up to you
xenial-blackOP•2y ago
ohh understoood