56 lines
1.6 KiB
HTML
56 lines
1.6 KiB
HTML
<h1>api</h1>
|
|
<a href="/api/foorum">foorum</a>
|
|
<br/>
|
|
<button onclick="getForum(prompt('ForumId: ', '1'))">GetForum</button>
|
|
<button onclick="getForums()">GetAllForums</button>
|
|
<button onclick="addForum()">AddForum</button>
|
|
<button onclick="searchForumAuthor(prompt('Author: ', 'veeb'))">SearchForumAuthor</button>
|
|
<code><pre id="output"></pre></code>
|
|
|
|
<script>
|
|
var out = document.getElementById("output");
|
|
|
|
function getForum(id) {
|
|
fetch("/api/foorum/"+id).then(resp => {
|
|
return resp.json();
|
|
}).then(data => {
|
|
console.log(data);
|
|
out.innerText = JSON.stringify(data, null, 2);
|
|
});
|
|
}
|
|
|
|
function getForums() {
|
|
fetch("/api/foorum").then(resp => {
|
|
return resp.json();
|
|
}).then(data => {
|
|
console.log(data);
|
|
out.innerText = JSON.stringify(data, null, 2);
|
|
});
|
|
}
|
|
|
|
function addForum() {
|
|
var dto = {
|
|
Author: "Veebileht",
|
|
Body: "Siia tuleb äge pikk sisu mingist asjast",
|
|
Description: "Siia kirjeldus",
|
|
Title: "Uhiuus postitus"
|
|
}
|
|
fetch("/api/foorum",
|
|
{
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
body: JSON.stringify(dto)
|
|
});
|
|
}
|
|
|
|
function searchForumAuthor(author) {
|
|
fetch("/api/search?author="+author).then(resp => {
|
|
return resp.json();
|
|
}).then(data => {
|
|
console.log(data);
|
|
out.innerText = JSON.stringify(data, null, 2);
|
|
});
|
|
}
|
|
</script> |