function list_tasks() { fetch(`${config.apiBase}/admin/task/list/${document.getElementById("neptun").value}`, { method: "GET", credentials: "same-origin", }) .then(response => response.json()) .then(data => { if (data.status !== 200) { alert(data.error); console.log(data); } else { let sum = 0; let table = document.getElementById("list"); table.innerHTML = ""; data.tasks.forEach(task => { let row = table.insertRow(); row.insertCell().innerText = task.description; row.insertCell().innerText = task.issuer; row.insertCell().innerText = task.points; row.insertCell().innerHTML = ``; sum += task.points; }); document.getElementById("sum").innerText = sum; } }) .catch(error => { console.log(error); }); } function remove(id) { fetch(`${config.apiBase}/admin/task/remove/${id}`, { method: "POST", credentials: "same-origin", }) .then(response => response.json()) .then(data => { if (data.status !== 200) { alert(data.error); console.log(data); } else { alert("removed"); list_tasks(); } }) .catch(error => { console.log(error); }); }