Retrieving body json when errors occur with useQuery
When my server responds with an error, it sometimes passes in an error message that is useful to the user. I want to pass that through to my React code but can't seem to do it, because I need to
my fetch code:
my query
my react code
but I want error.message to be the server response in some cases. Any advice?
throw new Error and I'm unable to call the await response.json() in this GET function or else the useQuery stops working, because it expects the promise as the return value. If I throw the error and then modify the error after the fact with the response body, my react code doesnt update. I'm in a pickle.my fetch code:
my query
my react code
but I want error.message to be the server response in some cases. Any advice?