Redux saves user data on login

This commit is contained in:
2019-10-03 10:58:45 -04:00
parent 8de496826a
commit f14e8bd970
4 changed files with 32 additions and 12 deletions

View File

@@ -37,5 +37,5 @@
"last 1 safari version"
]
},
"proxy": " http://localhost:5001/twistter-e4649/us-central1/api"
"proxy": "https://us-central1-twistter-e4649.cloudfunctions.net/api"
}

View File

@@ -10,7 +10,7 @@ export const loginUser = (loginData, history) => (dispatch) => {
const FBIdToken = `Bearer ${res.data.token}`;
localStorage.setItem('FBIdToken', FBIdToken);
axios.defaults.headers.common['Authorization'] = FBIdToken;
dispatch(getProfileInfo());
dispatch(getUserData());
dispatch({ type: CLEAR_ERRORS })
// Redirects to home page
history.push('/home');
@@ -23,13 +23,13 @@ export const loginUser = (loginData, history) => (dispatch) => {
});
}
// export const getProfileInfo = () => (dispatch) => {
// axios.get('/getProfileInfo')
// .then((res) => {
// dispatch({
// type: SET_USER,
// payload: res.data,
// })
// })
// .catch((err) => console.error(err));
// }
export const getUserData = () => (dispatch) => {
axios.get('/user')
.then((res) => {
dispatch({
type: SET_USER,
payload: res.data,
})
})
.catch((err) => console.error(err));
}