summaryrefslogtreecommitdiffstats
path: root/frontend/src/App.js
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/src/App.js')
-rw-r--r--frontend/src/App.js19
1 files changed, 17 insertions, 2 deletions
diff --git a/frontend/src/App.js b/frontend/src/App.js
index 38d8aef..51ba18c 100644
--- a/frontend/src/App.js
+++ b/frontend/src/App.js
@@ -9,7 +9,7 @@ import './App.css';
import axios from './axios';
import Activate from './Activate';
-const App = () => {
+const LoggedInRoutes = props => {
useEffect(() => {
const fetchUserInfo = async () => {
try {
@@ -24,8 +24,23 @@ const App = () => {
fetchUserInfo();
}, []);
+ return props.children;
+};
+
+const App = () => {
+ const fetchUserInfo = async () => {
+ try {
+ const resp = await axios.get('/user');
+ const { username } = resp.data;
+ userState.username = username;
+ } catch (err) {
+ userState.authError = err;
+ console.error(err);
+ }
+ };
+ fetchUserInfo();
return (
- <div className="App">
+ <div className="container">
<Router>
<Login path="/login" />
<Register path="/register" />