/**
async function loginUser() {
const email = document.getElementById('email').value html에서 정보 가져오기
const password = document.getElementById('password').value
try {
const response = await fetch(
'http://localhost:3001/users/sign-in', 우리가 만들었던것도 하나의 api이므로, 연결하기
{
method: 'POST', method 정하기
headers: { 헤더값
'Content-Type': 'application/json',
},
body: JSON.stringify({ email, password }), 바디값
}
)
const data = await response.json()
if (response.ok) { response.ok = return status가 200~299일때 true
alert('로그인되었습니다!')
// 로그인 성공 후 메인 페이지로 이동
window.location.href = 'index.html' 만들었던 html파일로 링크
} else {
alert('로그인에 실패했습니다. 다시 시도해주세요.')
}
console.log(data) // 응답 데이터 출력 또는 처리
} catch (error) {
console.error('로그인 에러:', error)
}
}
**/