summaryrefslogtreecommitdiffstats
path: root/frontend/src/App.js
diff options
context:
space:
mode:
authorJan Tuomi <jan.tuomi@eficode.com>2020-02-25 15:03:07 +0200
committerJan Tuomi <jan.tuomi@eficode.com>2020-02-25 15:03:07 +0200
commit0947b64287f7dd39310b7da10c7d8675c090b230 (patch)
treecfcd69bbd2eb6a9fb7a674e548a08904fcd6a415 /frontend/src/App.js
parent72b5fc9357f0100f4cc560c1430f7ea2d849eb40 (diff)
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" />