Trying to do a conditional fetch when a button click event, it works with the skipToken as mentioned in doc. However, when service return error (ex: 404), fetch wouldn't fire again.
Thinking it may be cache is preventing it to re-fetch so update the conditional skipToken with a count.
let [count, setCount] = useState(undefined);
const { data } = useUsersQuery(count ?? skipToken);
const getUsers = () => {
setCount(counter++);
}
.
.
<button onClick={() => getUsers()}>get users</button>
this work but created unnecessary data in redux store. There must be a better way?? may be invalidate the error cache? if that is the case how to invalidate? or some sort of force fetch when click again?
also already set refetchOnMountOrArgChange: true in endpoints.
kind of new to the RTK query, appreciate any pointers. Thanks!