szoe-pontok/static/js/list.js

30 lines
750 B
JavaScript
Raw Permalink Normal View History

2024-10-11 13:58:12 +00:00
function list() {
fetch(`${config.apiBase}/user/list`,
{
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;
data.tasks.forEach(task => {
let row = document.getElementById("list").insertRow();
row.insertCell().innerText = task.description;
row.insertCell().innerText = task.issuer;
row.insertCell().innerText = task.points;
sum += task.points;
});
document.getElementById("sum").innerText = sum;
}
})
.catch(error => {
console.log(error);
});
}
list();