From 108815151b9ca1ee220c6ea5edec289a1051eaa5 Mon Sep 17 00:00:00 2001 From: Nidboj132 Date: Sat, 6 May 2023 18:58:49 +0200 Subject: login --- frontend/src/components/login.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'frontend/src/components/login.js') diff --git a/frontend/src/components/login.js b/frontend/src/components/login.js index 8dea383..fc63760 100644 --- a/frontend/src/components/login.js +++ b/frontend/src/components/login.js @@ -1,6 +1,5 @@ import React from 'react'; import { Link } from "react-router-dom"; -import Cookies from 'js-cookie'; import "./login.css"; import img1 from "../imgs/login.png" @@ -14,8 +13,8 @@ function login() { window.location.href="https://lp.ardapektezol.com/api/v1/login" } function logout() { - Cookies.remove('token') setToken(null) + fetch(`/api/v1/token`,{'method':'DELETE'}) window.location.href="/" } const [token, setToken] = React.useState(null); @@ -25,7 +24,6 @@ React.useEffect(() => { .then(r => r.json()) .then(d => { setToken(d.data.token); - console.log(d); }) }, []); @@ -37,7 +35,7 @@ React.useEffect(() => { Authorization: token }}) .then(r => r.json()) - .then(d => {setProfile(d);console.log(d)}) + .then(d => setProfile(d.data)) }, [token]); @@ -46,13 +44,13 @@ return ( {isLoggedIn ? ( ) : ( - +