blob: 8687dc1f049311fbee7124a8cf866f2deff09453 (
plain)
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
|
async function btn_send_packet() {
let data = {
'comment': null,
};
if (document.getElementById('with_comment').checked) {
data.comment = document.getElementById('whisker_comment').value;
}
await post('/api/send_packet', data);
}
async function post(url, data) {
const params = {
method: "POST",
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(data),
};
let response = await fetch(url, params);
if (!response.ok) {
const text = await response.text();
alert(`Error Sending: ${response.statusText} ${text}`);
}
}
|