How to redirect from axios interceptor with react Router V4?

后端 未结 8 2135
忘了有多久
忘了有多久 2021-01-30 17:36

I want to make a redirection in axios interceptors when receiving a 403 error. But how can I access the history outside React components ?

In Navigating Programatically

8条回答
  •  旧时难觅i
    2021-01-30 18:42

    This works perfectly.

    window.location.href = `${process.env.REACT_APP_BASE_HREF}/login`;
    

提交回复
热议问题