Working forum post
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
<h1>api</h1>
|
||||
<a href="/api/foorum">foorum</a>
|
||||
<button onclick="getForums()">GetAll</button>
|
||||
<button onclick="getForums()">GetAllForums</button>
|
||||
<button onclick="addForum()">AddForum</button>
|
||||
<code><pre id="output"></pre></code>
|
||||
|
||||
<script>
|
||||
var out = document.getElementById("output");
|
||||
|
||||
function getForums() {
|
||||
var out = document.getElementById("output");
|
||||
fetch("/api/foorum").then(resp => {
|
||||
return resp.json();
|
||||
}).then(data => {
|
||||
@@ -13,4 +15,21 @@
|
||||
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)
|
||||
});
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user