Axios Operation how to operate react routing

I intercept the returned data in react. If the login fails or the token fails, I have to deal with it in the return interception. Do a route jump to the login interface to allow the user to log in again. Do you know how to use it? I don"t want to judge the

that must be processed before returning data in the business.
May.26,2022

routing is currently done through global variables
at the top entry app I defined window.router = this.props.history;

then call it on featch asios

   window._ROUTER_ = this.props.history;

Network request call

window._ROUTER_.push('/login');

this can be handled in the request interceptor

axiosInstance.interceptors.request.use(
    (config) => {
        if (tokenError) {
            // 
        } else {
            return config
        }
    },
    error => Promise.reject(error)
)

if the login fails, you specify a fixed status code, encapsulate the axios, and resolve if it returns correctly. If it is incorrect, you can judge what the status code is wrong and return to resolve or jump to your landing page directly.


window.location.href ='/ user/login'

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b2bdaa-2bae4.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b2bdaa-2bae4.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?