title: axios interceptors how to use them with axios.create()
body: <p>I have the following code which I import and use in a VueJS application.</p>
  <p>I want to be able to errors returned by the API centrally and it seems that interceptors would do the job for me but I don't understand where I set them up</p>
  <pre><code>import axios from 'axios'
  import store from './store/index'
  
  export default () =&gt; {
    try{
      var token = store.state.user.token.token
    }catch(err){
      var token = &quot;&quot;
    }
  
    return axios.create({
      baseURL: &quot;http://localhost:3333/api/v1&quot;,
      headers: {
        &quot;Authorization&quot;: `Bearer ${token}`
      }
    })
    
  }
  </code></pre>
  <p>I have tried this, but it does not work.</p>
  <pre><code>import axios from 'axios'
  import store from './store/index'
  
  axios.interceptors.request.use((config) =&gt; {
    console.info(&quot;debug &quot;, config);
    return config;
  }, (error) =&gt; {
    console.error(&quot;debug &quot;, error);
    return Promise.reject(error);
  });
  
  export default () =&gt; {
    try{
      var token = store.state.user.token.token
    }catch(err){
      var token = &quot;&quot;
    }
  
    return axios.create({
      baseURL: &quot;http://localhost:3333/api/v1&quot;,
      headers: {
        &quot;Authorization&quot;: `Bearer ${token}`
      }
    })
    
  }
  </code></pre>