-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
30 lines (26 loc) · 798 Bytes
/
Copy pathscript.js
File metadata and controls
30 lines (26 loc) · 798 Bytes
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
let endpoint,
data_to_send,
request;
// The current projects Endpoint
endpoint = "/api/register"
// The data to send in the current request
data_to_send = {
"token": "0217347fbdb52f16ea562bd939c1620a",
"github": "https://github.com/ArtBears/code2040app"
}
// The post request that I will send
request = (endpoint, payload) => {
xhr = new XMLHttpRequest();
let url = "http://challenge.code2040.org" + endpoint;
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-type", "application/json");
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status == 200) {
console.log(xhr.responseText);
console.log("sent");
}
}
let data = JSON.stringify(payload);
xhr.send(data);
}
request(endpoint, data_to_send);