I have a react-toolkit query that after a first successful request cached the response as expected, then in subsequent requests it's using the cached response. I'm ok with that.
In the store I have a slice that is watching the above mentioned query for matching fulfilled to get the response and transform it to then save some processed in the slice's state.
The problem is this: The first time the request is made I can get the response through a matcher, but then in subsequent calls the matcher do not match fulfilled cause the request is cached and no executed but I need to get the data in the slice, how can I?
This is a sample code:
const itemsSlice = createSlice({
name: 'items',
initialState,
reducers: {},
extraReducers: builder => {
builder.addMatcher(api.endpoints.getTokens.matchFulfilled, (state, {payload}) => {
// process the payload and update slice's state
})
}
})