Token fails in umijs, how to redirect to the home page

umijs generates routes by file, which is really convenient. Now, after logging in, if token fails, how do you monitor the failure of token? the main reason is that you can"t find an opportunity to do this. Are there any bosses using umijs

?
Mar.30,2021

token is invalid and can be judged by the server.
then return a status with invalid status, and you can handle it uniformly in fetch
for example: the server returns 455

fetch(url).then(respones => {
   if(respones.status === 455) {
        throw new Error('455');
   }
}).then(/**/)

then use the onError hook in index.js to get the exception and go directly to dispatch to your unauthorized page.

Menu