-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathsign_up.html
More file actions
48 lines (36 loc) · 1.79 KB
/
sign_up.html
File metadata and controls
48 lines (36 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<script src="https://code.jquery.com/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
<!-- 커스터마이징한 axiosInstace 들고있는 파일 -->
<script src="/custom_axios.js"></script>
회원가입 화면</br></br>
이메일 : <input id="emailInput" type="text" placeholder="이메일 입력"></input> </br>
비밀번호 : <input id="pwInput" type="text" placeholder="비밀번호 입력"></input> </br>
닉네임 : <input id="nickNameInput" type="text" placeholder="닉네임 입력"></input> </br>
<button id="signUpBtn">회원가입</button>
<script>
$('#signUpBtn').click(function() {
// 이메일 / 비번 / 닉네임 입력값을 각각의 변수에 저장
let email = $('#emailInput').val()
let pw = $('#pwInput').val()
let nick = $('#nickNameInput').val()
// 받아낸 값들을 폼데이터에 담아두자. => PUT으로 전송 예정
const form = new FormData()
form.append('email', email)
form.append('password', pw)
form.append('nick_name', nick)
// 가져온 스크립트에 있는 axiosInstance를 이용해 회원가입 요청 실행
axiosInstance.put('/user', form)
.then(function (res) {
// 성공시 얼럿 띄우고 로그인화면으로
if (res.data.code == 200) {
alert('회원가입 성공')
$(location).attr('href', "login.html")
}
})
.catch(function (error) {
// 실패시 error의 응답에 담긴 message를 얼럿으로
alert(error.response.data.message)
})
})
</script>