30 lines
750 B
JavaScript
30 lines
750 B
JavaScript
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(); |