From e07797557ba47ed22a499967a00b4624ae3cf74e Mon Sep 17 00:00:00 2001 From: Kristoffer Juelsen Date: Tue, 26 Apr 2022 13:36:56 +0200 Subject: [PATCH] reverted fetch to not use local method --- src/client/src/FrontPage.js | 56 ++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/src/client/src/FrontPage.js b/src/client/src/FrontPage.js index 4f79a25..1e9d9bb 100644 --- a/src/client/src/FrontPage.js +++ b/src/client/src/FrontPage.js @@ -205,36 +205,36 @@ let showError = (message) => {}; export default function App() { const [user, setUser] = React.useState({}); - // let fetchUser = () => { - // fetch(process.env.REACT_APP_API_URL + `/users/getSavedUser`) - // .then(res => res.json()) - // .then(data => { - // if (data.status !== "OK") { - // setUser({ isManager: false, isLoggedIn: false }); - // console.log(data.data); // "No user logged in" - // return; - // } - // let u = data.data; - // u.isLoggedIn = true; - // console.log("User is logged in") - // setUser(u); - // }) - // .catch((err) => { - // showError(err.message); - // setUser({ isManager: false, isLoggedIn: false }); - // }); - // } - // // Debug mode, allow all: let fetchUser = () => { - setUser({ - name: "TEST USERTEST", - isManager: true, - isLoggedIn: true, - email: "testesen@gmail.com", - asuraId: "123456789", - googleId: "234" - }); + fetch(process.env.REACT_APP_API_URL + `/users/getSavedUser`) + .then(res => res.json()) + .then(data => { + if (data.status !== "OK") { + setUser({ isManager: false, isLoggedIn: false }); + console.log(data.data); // "No user logged in" + return; + } + let u = data.data; + u.isLoggedIn = true; + console.log("User is logged in") + setUser(u); + }) + .catch((err) => { + showError(err.message); + setUser({ isManager: false, isLoggedIn: false }); + }); } + // // Debug mode, allow all: + // let fetchUser = () => { + // setUser({ + // name: "TEST USERTEST", + // isManager: true, + // isLoggedIn: true, + // email: "testesen@gmail.com", + // asuraId: "123456789", + // googleId: "234" + // }); + // } React.useEffect(() => { fetchUser();