endpoint to get tasks

This commit is contained in:
Florian Hoss 2022-04-04 12:26:36 +02:00
parent 9e058e4f03
commit 712af41c28
5 changed files with 28 additions and 3 deletions

View file

@ -12,7 +12,7 @@
<div class="fs-3">{{ .title }}</div>
<hr>
{{template "userForm" .}}
<a class="link-secondary" href="/register">Register instead</a>
<a class="link-secondary" href="/view/register">Register instead</a>
</div>
{{template "scripts" .}}

View file

@ -12,7 +12,7 @@
<div class="fs-3">{{ .title }}</div>
<hr>
{{template "userForm" .}}
<a class="link-secondary" href="/login">Login instead</a>
<a class="link-secondary" href="/view/login">Login instead</a>
</div>
{{template "scripts" .}}

View file

@ -15,7 +15,14 @@
{{template "scripts" .}}
<script>
userLoggedIn().then((loggedIn) => !loggedIn && redirect("/view/login"));
userLoggedIn().then((loggedIn) => !loggedIn ? redirect("/view/login") : getAllTasks());
async function getAllTasks() {
const response = await fetch("/tasks", {method: 'GET', headers: myHeaders});
const json = await response.json();
console.log(json);
}
</script>
</body>
</html>