22 lines
480 B
JavaScript
22 lines
480 B
JavaScript
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);
|
|
});
|
|
} |