blob: dff08030ee9ec5897e6b2b4c6e8c9b4289d129ba (
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
|
class CommentForm {
constructor(domain, post) {
this.domain = domain;
this.post = post;
this.form_element = document.getElementById("comment-form");
this.form_element.addEventListener("submit", this.submit);
}
async submit(event) {
const form = new FormData(event.target);
form.append("domain", window.location.hostname);
try {
const response = await fetch(`https://${this.domain}/${this.post}/comments`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: form
});
const body = response.body;
} catch(error) {}
}
}
|