From f902dbce95d3ab89da27f5c56f62a912b16b90b9 Mon Sep 17 00:00:00 2001 From: Taewan Kim Date: Fri, 15 Sep 2023 17:36:48 +0900 Subject: [PATCH] Add error handling code during login check (#216) 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 --- frontend/src/pages/Home.jsx | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/frontend/src/pages/Home.jsx b/frontend/src/pages/Home.jsx index a0066dac..419f20a8 100644 --- a/frontend/src/pages/Home.jsx +++ b/frontend/src/pages/Home.jsx @@ -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) {