1export const loadUser = () => (dispatch, getState) => {
2 if (!getState().auth.token) {
3 dispatch({ type: LOGIN_FAIL });
4 return;
5 }
6
7 // User Loading
8 dispatch({ type: USER_LOADING });
9
10 axios
11 .get('/api/auth/user', tokenConfig(getState))
12 .then(res => {
13 dispatch({
14 type: USER_LOADED,
15 payload: res.data,
16 });
17 })
18 .catch(err => {
19 console.warn(`Error returned: ${err}.`);
20
21 dispatch({
22 type: AUTH_ERROR,
23 });
24 });
25};
1const Home: React.FC<Person> = (person) => {
2 useEffect(() => {
3 }, []);
4 return (
5 <>
6 <div>
7 <h3>{person.name}</h3>
8 <h3>{person.idCard}</h3>
9 </div>
10 </>
11 );
12};