Answer the question
In order to leave comments, you need to log in
How to call transition to another page outside of action?
I use Axios for requests. Created an interceptor for the response from the server. If the server returns a 401 error, I need to take the refresh token and send it to the server to refresh the access token.
Here is the interceptor:
Axios.interceptors.response.use(function (response) {
console.log(response);
if(isResponseOK(response))
return response;
const originalRequest = response.config;
Axios.post(REFRESH_TOKENS, {
refreshToken: AppStore.retrieve("refreshToken")
})
.then(function (response) {
})
.catch(function (error) {
});
}, function (error) {
console.log(error);
return Promise.reject(error);
});
Answer the question
In order to leave comments, you need to log in
store, dispatch can be obtained from the file in which configureStore() is called, for this you need to export it.
For example like this:
import React from 'react';
import { Provider } from 'react-redux';
import configureStore from '../store/configureStore';
import CoreLayout from './CoreLayout';
export const store = configureStore();
const App = () => (
<Provider store={store}>
<CoreLayout />
</Provider>
);
export default App;
import { store } from '../../containers/App';
store.dispatch(signOutAction());
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question