랜딩페이지에 로그아웃 버튼을 추가함
function LandingPage() {
const onClickHandler = () => {
axios.get('/api/users/logout')
.then(response => {
if(response.data.success) {
navigate('/login') //페이지 이동
} else {
alert('로그아웃 실패')
}
})
}
return (
<button onClick={onClickHandler}>
로그아웃
</button>
</div>
)
}
'웹 > React' 카테고리의 다른 글
[React-icon/에러] Attempted import error: '' is not exported from 'react-icons/fa' (0) | 2023.08.20 |
---|---|
[React] 인증 체크 (0) | 2023.08.16 |
[React] 회원가입 페이지 만들기 (0) | 2023.08.14 |
[React] 로그인 페이지 만들기 (0) | 2023.08.13 |
[React] react hooks (0) | 2023.08.12 |
댓글