title: Prevent Caching on a specific RTK Query Endpoint
body: <p>I am using rtq query and i have an endpoint that takes azure-ad oid from the global store and makes a query to the backend to check if the user exists on the backend to check if the user exists. If the user exists then I redirect the user to the dashboard else I do not redirect the user.</p>
  <p>The problem is that despite trying to prevent caching on that endpoint, it still uses the cached data and by the time the real data comes from the server, the redirect has already happened. Below are some of the steps I have taken to prevent this from happening.</p>
  <ol>
  <li>Using refetch</li>
  <li>Setting refetchOnMountOrArgChange: true,</li>
  <li>Setting  keepUnusedDataFor: 0.0001 to invalidate the cache almost immediately</li>
  </ol>
  <p>The point is that I do not want this endpoint to use any cached data.</p>
  <p>Below is my component:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code> const [isSignedIn] = useIsSignedIn();
    const history = useHistory();
    const dispatch = useAppDispatch();
    const ongraphLogin = async (role: string) =&gt; {
      if (Providers.globalProvider.login) {
        dispatch(setloginType(role));
  
        await Providers.globalProvider.login();
      }
    };
    const userState = useAppSelector(state =&gt; state.userState);
  
   
    console.log(userState?.currentUser?.id);
    const { data, error, isLoading, refetch } = useGetUserByOidQuery(userState?.currentUser?.id, {
      skip: isSignedIn,
      refetchOnMountOrArgChange: true
    });
    
    useEffect(() =&gt; {
      refetch();
      // console.log(res);
      if (isSignedIn) {
        console.log('I am in');
        // Check if the user exists in the ndovysystem
        if (data?.status === 'success') {
          console.log(data);
          history.push('/user');
        } else if (userState.loginType === 'volunteerRegistration') {
          history.push('/register/volunteer');
        } else if (userState.loginType === 'menteeRegistration') {
          history.push('/register/mentee');
        }
      }
    }, [isSignedIn, data]);</code></pre>
  </div>
  </div>
  </p>
  <p>Below is the endpoint</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>import { ndovuAPI } from './ndovuAPI';
  
  export const ndovuUserAPI = ndovuAPI.injectEndpoints({
    endpoints: builder =&gt; ({
      getUserByOid: builder.query({
        query: (oid: string) =&gt; `/users/oid/${oid}`,
        keepUnusedDataFor: 0.0001
      })
    })
  });
  
  // Export hooks for usage in functional components
  export const { useGetUserByOidQuery} = ndovuUserAPI;</code></pre>
  </div>
  </div>
  </p>
  <p>Kindly help me solve this.</p>