best way to handle errors of api that returns status 200 w error field
Is there a better way than an if / else condition onSuccess if your API returns 200 for errors ?
my api returns always a 200 with fields { data, errors } and I would love to be able to get the errors in the onError() method
4 Replies
fair-rose•16mo ago
return data field and throw errors field in queryFn?
adverse-sapphireOP•16mo ago
yup but that would make me add this for every queryFn so i would end up w a lot of extra code. I am looking for a generic solution
which I think I found modifying the querycache on success at the client level
sensitive-blue•16mo ago
onSuccess on the queryCache + throw there could work
adverse-sapphireOP•16mo ago
yup, thats what i did 👏 This is pretty handy since unfortunately stuff like graphql will always return 200