diff --git a/WebApi/index.html b/WebApi/index.html index 6685b29..feb75e7 100644 --- a/WebApi/index.html +++ b/WebApi/index.html @@ -1,9 +1,8 @@ -
@@ -39,11 +38,16 @@
});
}
- function addForum(title) {
+ function addForum(title, description, body, author) {
+ if (title == null) throw new Error("title unset");
+ if (description == null) throw new Error("description unset");
+ if (body == null) throw new Error("body unset");
+ if (author == null) throw new Error("author unset");
+
var dto = {
- Author: "Veebileht",
- Body: "Siia tuleb äge pikk sisu mingist asjast",
- Description: "Siia kirjeldus",
+ Author: author,
+ Body: body,
+ Description: description,
Title: title
}
fetch("/api/foorum",
@@ -71,12 +75,15 @@
}
function deleteForum(id, permanent) {
+ if (id == null) throw new Error("Forum id is unset");
+
var q = "";
if (permanent) {
q = "?permanent=true";
}
- fetch("/api/foorum/"+id+q, { method: 'DELETE'});
+ fetch("/api/foorum/" + id + q, { method: 'DELETE' })
+ .then(resp => getForums());
}
function searchForum(what, author) {
@@ -88,12 +95,18 @@
});
}
- function addPost(id, title, body) {
+ function addPost(id, title, body, author) {
+ if (id == null) throw new Error("forum id is unset");
+ if (title == null) throw new Error("title is unset");
+ if (body == null) throw new Error("body is unset");
+ if (author == null) throw new Error("author is unset");
+
var dto = {
- Author: "Ajax",
+ Author: author,
Body: body,
Title: title
}
+
fetch("/api/foorum/"+id,
{
method: 'POST',