invalidatesTags works even if the request is 422 http status #3514
-
Hello, I have a mutation code in the form of the following code. invalidatesTags when request is 200. While waiting for it to work, it works in http statuses such as 422, 409. Is this a problem or am I setting it up wrong?
|
Beta Was this translation helpful? Give feedback.
Answered by
EskiMojo14
Jun 9, 2023
Replies: 1 comment 4 replies
-
if you provide an array for invalidatesTags, it will invalidate those tags for both successful and unsuccessful requests. if you only want to invalidate tags for successful requests, you should provide a callback: testMutation: builder.mutation({
query: (body) => ({
url: 'test/services',
method: 'POST',
body,
}),
invalidatesTags: (result, error, arg) => !error ? ptpApi.invalidatesTags(['testInvalidatesTags']) : [],
extraOptions: {
toastSuccessMessageKey: 'testMutation',
toastErrorMessageKey: 'testMutation',
},
}), |
Beta Was this translation helpful? Give feedback.
4 replies
Answer selected by
phoique
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
if you provide an array for invalidatesTags, it will invalidate those tags for both successful and unsuccessful requests.
if you only want to invalidate tags for successful requests, you should provide a callback: