I wonder if it possible to dispatch an action from another reducer in the API Slice
of Redux RTK. Assuming I have this
getSomething: builder.query<SomeProps, void>({
query: () => ({
url: "...",
headers: {
'Content-Type': 'application/json',
}
}),
Is it possible to have something in there like onSuccess
(assuming the getSomething()
returns a 200
/anything that resolves to a success)
getSomething: builder.query<SomeProps, void>({
query: () => ({
url: "...",
headers: {
'Content-Type': 'application/json',
}
}),
onSuccess: (response: SomeProps, {dispatch}) => {
dispatch(someActionFromAnotherReducer(response))
}