#best way to handle errors of api that returns status 200 w error field

5 messages · Page 1 of 1 (latest)

desert wind
#

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

fresh belfry
#

return data field and throw errors field in queryFn?

desert wind
#

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

serene bane
#

onSuccess on the queryCache + throw there could work