title: How to add global loading/spin effect in axios interceptor for a React project
body: <p>I am use axios for API call in a React project, and I want to add a loading or spinning effect globally in between a api call's request and response in my axios interceptor, here is the code of my interceptor.</p>
  
  <pre><code>import Axios from 'axios'
  
  Axios.interceptors.request.use(function (config) {
    // spinning start to show
    const token = window.localStorage.token;
    if (token) {
       config.headers.Authorization = `token ${token}`
    }
    return config
  }, function (error) {
    return Promise.reject(error);
  });
  
  Axios.interceptors.response.use(function (response) {
    // spinning hide
    return response;
  }, function (error) {
    return Promise.reject(error);
  });
  </code></pre>