Skip to content

Commit

Permalink
Add error handling code during login check (#216)
Browse files Browse the repository at this point in the history
An error happens when a request to add the new member to db
is called twice in a row due to StrictMode.

Signed-off-by: Taewan Kim <[email protected]>
  • Loading branch information
tiokim authored Sep 15, 2023
1 parent d5c29a5 commit f902dbc
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions frontend/src/pages/Home.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,18 @@ export const Home = () => {
const [username, setUsername] = useState("");

useEffect(() => {
axios.get("/login/check").then((loginresponse) => {
if (loginresponse.data.isLoggedIn) {
setIsLoggedIn(loginresponse.data.isLoggedIn);
axios.get("/user/info").then((userInfoResponse) => {
setUsername(userInfoResponse.data);
});
}
});
axios.get("/login/check")
.then((loginresponse) => {
if (loginresponse.data.isLoggedIn) {
setIsLoggedIn(loginresponse.data.isLoggedIn);
axios.get("/user/info").then((userInfoResponse) => {
setUsername(userInfoResponse.data);
});
}
})
.catch(function(error) {
console.log(error.toJSON());
});
}, []);

function truncateName(name) {
Expand Down

0 comments on commit f902dbc

Please sign in to comment.