invalitate/clear whole api data on user logout #1406
Unanswered
wuifdesign
asked this question in
Q&A
Replies: 1 comment 8 replies
-
Are you looking for https://redux-toolkit.js.org/rtk-query/api/created-api/cache-management-utils#resetapistate ? |
Beta Was this translation helpful? Give feedback.
8 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I want to invalidate a whole api if a user gets logged out (cookie expired and the server response 401).
I extended the baseQuery to do this:
First way would be to use tags, but i can't find a way to
invalidatesTags
from outside a mutation and invalidation will still keep the data in the redux store (if i understand it right). i would need something likeapi.invalidateTags(['Auth'])
and add theAuth
tag to all endpoints. but still i will not be able to invalitate it inside thebaseQueryWithAuthCheck
.Better way would be to get the data out of the redux store. something like
api.clear()
which removes all stored data and triggers refetch for all active subscriptions.Beta Was this translation helpful? Give feedback.
All reactions