Skip to content

Commit

Permalink
checkUsert Logged in
Browse files Browse the repository at this point in the history
  • Loading branch information
andrrsin committed Mar 9, 2024
1 parent 1848505 commit 557258a
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion webapp/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,26 @@ import Container from '@mui/material/Container';
import Typography from '@mui/material/Typography';
import Link from '@mui/material/Link';
import { useEffect } from 'react';
import axios from 'axios';
function App() {
const [showLogin, setShowLogin] = useState(true);
const [user, setUser] = useState({});
const apiEndpoint = process.env.REACT_APP_API_ENDPOINT || 'http://localhost:8000';
const handleToggleView = () => {
setShowLogin(!showLogin);
};

const checkUser = () => {
const token = localStorage.getItem('uToken');
if (token) {
axios.get(`${apiEndpoint}/self`, {
headers: {
Authorization: token,
},
}).then((response) => {
setUser(response.data);
});
}
};
return (
<Container component="main" maxWidth="xs">
<CssBaseline />
Expand Down

0 comments on commit 557258a

Please sign in to comment.