관리 메뉴

프론트엔드 정복하기

React_REDUX-로그아웃 본문

React/강의-boilerplate

React_REDUX-로그아웃

GROWNFRESH 2020. 5. 27. 14:19

1. 로그아웃 button 'click' event 만들기

<button onClick={onClickHandler}>

 

2. onClickHandler function 선언

 

    const onClickHandler = () => {

        axios.get('/api/users/logout')

            .then(reponse=>{

                if(reponse.data.success){

                    props.history.push("/login")

                }else{

                    alert('로그아웃 하는 데 실패했습니다.')

                }

            })

    }