Do the link jump in the axios interceptor in the react code

this is the axios interceptor used in React. How to do a react route transfer in the interceptor?

import Axios from "axios"

Axios.interceptors.request.use(function (config) {
  let token = window.localStorage.token;
  if (token) {
    config.headers.Authorization = `token ${token}`
  }
  return config
}, function (error) {
  return Promise.reject(error);
});

Axios.interceptors.request.use(function (config) {
  return config
}, function (error) {
  // react
  return Promise.reject(error);
});
Mar.14,2021

//react-router-dom (rrouter v4),browercreateHashHistorycreateBrowerHistory
import {createHashHistory} from 'history';
const history = createHashHistory();
history.push('');

//react-router v3browerhashHistorybrowerHistory
import {hashHistory} from 'react-router';
hashHistory.push('');

import {HashRouter} from 'react-router-dom'
const router = new HashRouter()
router.history.push('/')

recently also encountered = _, =
but my needs are not very complicated, so I violently location.href='xxx' jumped
and waited for other veteran drivers to answer


ask how to configure the interceptor in the react project

configure a separate js file and introduce it into index.js

Menu