import React from 'react'
import { Provider } from 'react-redux'
import axios from 'axios'
import { store, history } from './redux/store'
import PublicRoutes from './router'
import '../src/style/styles.less'

axios.defaults.baseURL = 'https://encontrar-stage.herokuapp.com/v1'
axios.defaults.headers.common['Content-Type'] = 'application/json'
axios.interceptors.response.use(function (response) {
    return response;
  }, function (error) {
    if (error.response.status === 401) {
      localStorage.setItem('auth_token', null)
    }
    return Promise.reject(error);
  });

const DashApp = () =>
  <Provider store={store}>
    <PublicRoutes history={history} />
  </Provider>;

export default DashApp;

import React from 'react'
import { Provider } from 'react-redux'
import axios from 'axios'
import { store, history } from './redux/store'
import PublicRoutes from './router'
import '../src/style/styles.less'

axios.defaults.baseURL = 'https://encontrar-stage.herokuapp.com/v1'
axios.defaults.headers.common['Content-Type'] = 'application/json'
axios.interceptors.response.use(function (response) {
    if (response.status === 401) {
    	localStorage.setItem('auth_token', null)
    }
    return response;
  }, function (error) {
    localStorage.setItem('auth_token', null)
    return Promise.reject(error);
  });

const DashApp = () =>
  <Provider store={store}>
    <PublicRoutes history={history} />
  </Provider>;

export default DashApp;

--- 
+++ 
@@ -8,12 +8,11 @@
 axios.defaults.baseURL = 'https://encontrar-stage.herokuapp.com/v1'
 axios.defaults.headers.common['Content-Type'] = 'application/json'
 axios.interceptors.response.use(function (response) {
-    if (response.status === 401) {
-    	localStorage.setItem('auth_token', null)
-    }
     return response;
   }, function (error) {
-    localStorage.setItem('auth_token', null)
+    if (error.response.status === 401) {
+      localStorage.setItem('auth_token', null)
+    }
     return Promise.reject(error);
   });
 
Fix partial the error 401 handler
