Commit 4ab45a07 authored by Milan Iliev's avatar Milan Iliev

Server deletes

parent 36e83d84
......@@ -25,6 +25,15 @@ router.put("/tasks/:id", async (context) => {
})
router.delete("/tasks/:id", async (context) => {
let task_id = context.request.params["id"]
let task = tasks.find((task) => task.id === task_id )
tasks.remove(task)
context.response.status = 204
})
const app = new Koa()
app.use(serve(`${__dirname}/../web`))
app.use(logger())
......
......@@ -22,6 +22,7 @@ class TaskController {
remoteTask(task){
this.tasks.remove(task)
this.view.removeTaskView(task)
this.requestDelete(task)
}
async refresh(){
......@@ -41,6 +42,12 @@ class TaskController {
}
})
}
async requestDelete(task){
let tasks_response = await fetch(`/tasks/${task.id}`, {
method: "DELETE"
})
}
}
export default TaskController
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment