title: React access redux store in axios interceptor
body: <p>I want to access redux store in axios's interceptor which configures jwt token, so I import the store into the API.js file. But it immediately logged out some errors.<a href="https://i.stack.imgur.com/5L1MC.png" rel="noreferrer"><img src="https://i.stack.imgur.com/5L1MC.png" alt="enter image description here" /></a></p>
  <p>Here's the axios instance</p>
  <pre><code>import axios from &quot;axios&quot;;
  import { store } from '../redux/store';
  
  export const SERVERURL = &quot;some url&quot;;
  
  axios.defaults.withCredentials = true;
  const API = axios.create({ baseURL: &quot;some url&quot; });
  
  API.interceptors.request.use(req =&gt; {
    // something I want to do
    return req;
  });
  
  export default API;
  </code></pre>
  <p>Here's the store.js</p>
  <pre><code>import { configureStore } from &quot;@reduxjs/toolkit&quot;;
  import userReducer from &quot;./user&quot;;
  
  export const store =  configureStore({ reducer: { user: userReducer } });
  </code></pre>
  <p>And the index.js</p>
  <pre><code>import React from &quot;react&quot;;
  import ReactDOM from &quot;react-dom&quot;;
  import { BrowserRouter } from &quot;react-router-dom&quot;;
  import &quot;./index.css&quot;;
  import App from &quot;./App&quot;;
  import {store} from &quot;./redux/store&quot;;
  import { Provider } from &quot;react-redux&quot;;
  
  ReactDOM.render(
    &lt;Provider store={store}&gt;
      &lt;BrowserRouter&gt;
        &lt;App /&gt;
      &lt;/BrowserRouter&gt;
    &lt;/Provider&gt;,
    document.getElementById(&quot;root&quot;)
  );
  </code></pre>
  <p>I want to know what would be the problem?</p>