T
TanStack3y ago
fair-rose

Query keeping cached data when api returns error on invalidate

Lets say I have a page which is displaying data from an API, a list of cars! I'm deleting manually every single car from this api by mutating and then onSuccess I'm invalidating the key of the api above (cars) to get the updated data. The error is, when I delete all cars and invalidate the query, the api return error, but the query is keeping the old data on cache. How can I clear cache when Query call get error?
1 Reply
eastern-cyan
eastern-cyan3y ago
what's the old data in the cache after you've deleted everything? when the invalidation returns an error, the query should go to error state ...

Did you find this page helpful?