diff --git a/src/api/FectUser.js b/src/api/FectUser.js index 1fb6f26..4a4342f 100644 --- a/src/api/FectUser.js +++ b/src/api/FectUser.js @@ -1,10 +1,12 @@ import axios from 'axios'; -export async function fetchUserLogin(checkEmail, checkPassword) { - const response = await axios.post(`/api/login`, { email: checkEmail, password: checkPassword }); - const data = await response.data; - return data; -} +// export async function fetchUserLogin(checkEmail, checkPassword) { +// const response = await axios.post(`/api/login`, { email: checkEmail, password: checkPassword}); +// const data = await response.data; +// console.log(data) +// console.log(response) +// return data; +// } export async function fetchUserSingup(checkName, checkEmail, checkPassword) { const response = await axios.post(`/api/sign-up`, { name: checkName, email: checkEmail, password: checkPassword }); diff --git a/src/components/Headers.js b/src/components/Headers.js index 6039afb..1bba04e 100644 --- a/src/components/Headers.js +++ b/src/components/Headers.js @@ -124,8 +124,6 @@ export default function SearchAppBar() { fetchLogout().then(() => { setUserCookie(null); - - // 쿠키 삭제 deleteCookie('email'); deleteCookie('name'); diff --git a/src/pages/SignInPage.js b/src/pages/SignInPage.js index a829c34..60e6a4b 100644 --- a/src/pages/SignInPage.js +++ b/src/pages/SignInPage.js @@ -47,21 +47,36 @@ export default function SingInPage({ data }) { }; - const handleSubmit = async(event) => { - event.preventDefault(); + + const handleSubmit = async (event) => { + event.preventDefault(); + console.log(userLogin.email); + try { + const response = await axios.post('/api/login', userLogin); + // setCookie('name', response.name, { path: '/' }); + // setCookie('email', response.email, { path: '/' }); + // setCookie('id', response.id, { path: '/' }); + navigate('/'); + + } catch (error) { + alert('아이디 또는 패스워드가 맞지 않습니다'); + } + + + - fetchUserLogin(userLogin.email, userLogin.password, userLogin.id) - .then((response) => { - // const encryptedId = encrypt(response.id); - // 쿠키 설정 - setCookie('name', encodeURIComponent(response.name)); - setCookie('email', response.email); - setCookie('id', response.id) - navigate(`/`); - }) - .catch(error => { - alert("아이디 또는 패스워드가 맞지 않습니다"); - }); + // fetchUserLogin(userLogin.email, userLogin.password, userLogin.id) + // .then((response) => { + // // const encryptedId = encrypt(response.id); + // // 쿠키 설정 + // setCookie('name', encodeURIComponent(response.name)); + // setCookie('email', response.email); + // setCookie('id', response.id) + // navigate(`/`); + // }) + // .catch(error => { + // alert("아이디 또는 패스워드가 맞지 않습니다"); + // }); }; // const encrypt = (value) => {