How to redirect from axios interceptor with react Router V4?

后端 未结 8 2287
忘了有多久
忘了有多久 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条回答
  •  爱一瞬间的悲伤
    2021-01-30 18:40

    I am using react-router-dom and it has "history" props which can be used in transition to new route

     history.push('/newRoute')
    

提交回复
热议问题