So, I have an auth related reducer like this:
export default function reducer(state = initialState, action = {}) { switch (action.type) { case LOAD: return { ...state, loading: true, } case LOAD_SUCCESS: return { ...state, loading: false, loaded: true, jwt: action.jwt, } case LOAD_FAIL: return { ...state, loading: false, loaded: false, error: true, errorMessage: action.error, } case LOGIN: return { ...state, loaded: false, loggingIn: true, } case LOGIN_SUCCESS: return { ...state, loaded: true, loggingIn: false, jwt: jwtDecode(action.result.token), } case LOGIN_FAIL: return { ...state, loggingIn: false, user: null, error: true, errorMessage: action.error, } case LOGOUT: return { ...state, loggingOut: true, } case LOGOUT_SUCCESS: return { ...state, loggingOut: false, user: null, jwt: null, } case LOGOUT_FAIL: return { ...state, loggingOut: false, error: true, errorMessage: action.error, } default: return state } }
Where LOAD is the loading of a previously saved (either cookie or JWT) auth, and LOGIN / LOGOUT is self-explanatory.
I need to activate some additional actions after a successful download or login.
I want to execute a GET request in order to get some personal data about a user that is accessible only after logging in, and store this personal data in a redux store that will be used by various parts of the application. How to do it?