-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
28 lines (26 loc) · 813 Bytes
/
test.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
function getJwtToken() {
return sessionStorage.getItem("hasura-jwt-token")
}
function setJwtToken(token) {
sessionStorage.setItem("jwt", token)
}
document.getElementById("loginbutton").onclick = ()=>{
//console.log("JWT: ",getJwtToken());
getToken()
}
function getToken() {
let name = document.getElementsByName("uname")[0].value
let pwd = document.getElementsByName("psw")[0].value
//console.log("name:",name," pwd:",pwd)
let encoded = btoa(name+':'+pwd)
console.log("encoded: ",encoded);
fetch("https://zone01normandie.org/api/auth/signin", {
method: 'POST',
headers: {
mode: 'cors',
Authorization: `Basic ${encoded}`,
}
}).then((response)=>{
return response.json()
}).then((data)=>{console.log(data);})
}