szoe-pontok/static/js/add.js

22 lines
480 B
JavaScript
Raw Permalink Normal View History

2024-10-11 13:58:12 +00:00
var add_form = document.getElementById("add_form");
function add() {
fetch(`${config.apiBase}/admin/task/add`,
{
method: "POST",
credentials: "same-origin",
body: new FormData(add_form)
})
.then(response => response.json())
.then(data => {
if (data.status !== 200) {
alert(data.error);
console.log(data);
} else {
alert("task added");
}
})
.catch(error => {
console.log(error);
});
}