generated from CodeChefVIT/template
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp1.js
37 lines (32 loc) · 1.1 KB
/
app1.js
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
//login
let main
window.localStorage.clear()
document.getElementById('auth').addEventListener('click', function auth () {
const data = JSON.stringify({
email: document.getElementById('uid').value,
password: document.getElementById('pass').value
})
const xhr = new XMLHttpRequest()
xhr.withCredentials = false
xhr.responseType = 'json'
xhr.addEventListener('readystatechange', function () {
if (this.readyState === 4) {
if (xhr.status == 200) {
console.log(this.response.success)
window.localStorage.setItem('jwttoken', this.response.token)
// main = window.open('teamlist.html')
window.location.assign('teamlist.html')
// main.onload=function() {
// const jwttoken1 = window.localStorage.getItem('jwttoken')
// main.console.log(jwttoken1)
// load(jwttoken1)
// }
} else {
alert('retry')
}
}
})
xhr.open('POST', base + '/admin/login')
xhr.setRequestHeader('Content-Type', 'application/json')
xhr.send(data)
})