-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
21 lines (20 loc) · 841 Bytes
/
script.js
File metadata and controls
21 lines (20 loc) · 841 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
const API_URL = "https://esihub.herokuapp.com";
const url_params = new URLSearchParams(window.location.search);
if(url_params.has("code")){
const alert = document.getElementById("join-with-gh");
fetch(`${API_URL}/invite?code=${url_params.get("code")}`)
.then((response) => response.json())
.then((data) => {
if(!data.hasOwnProperty("success")) throw Error(JSON.stringify(data));
if(data.success) window.location.replace("https://github.com/HubESI");
else{
alert.style.color = "red";
alert.innerHTML = data.github_user + ". " + data.message;
}
})
.catch((error) => {
alert.style.color = "red";
alert.innerHTML = "An error occurred";
console.log('Request failed', error);
});
}