From 9d532e86571453c5db59979416fc0428f2e80a22 Mon Sep 17 00:00:00 2001 From: Nidboj132 Date: Sat, 6 May 2023 17:51:01 +0200 Subject: login test --- frontend/src/components/login.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'frontend/src/components/login.js') diff --git a/frontend/src/components/login.js b/frontend/src/components/login.js index 507cf5b..558bc8f 100644 --- a/frontend/src/components/login.js +++ b/frontend/src/components/login.js @@ -16,13 +16,15 @@ function logout() { setToken(null) window.location.href="/" } - const [token, setToken] = React.useState(null); const isLoggedIn = token !== null; React.useEffect(() => { fetch(`/api/v1/token`) - .then(r => {console.log(r)}) - .then(d => {setToken(d.data.token);console.log(d)}) + .then(r => r.json()) + .then(d => { + setToken(d.data.token); + console.log(d); + }) }, []); const [profile, setProfile] = React.useState(); @@ -32,10 +34,11 @@ React.useEffect(() => { 'Content-Type': 'application/json', Authorization: token }}) - .then(r => {console.log(r)}) + .then(r => r.json()) .then(d => {setProfile(d);console.log(d)}) }, []); + return ( <> {isLoggedIn ? ( -- cgit v1.2.3