I have a simple todo app and am working on the edit task feature. My backend appears to be working correctly when tested. I am looking for req.body.description. I am editing the task by id. When I save the edit, nothing happens inside my database. My function is as follows, why does this not work?
function editTask(task) {
const id = task.parent().parent().attr('id');
const descript = task.parent().prev().text();
axios.put('http://localhost:5000/api/tasks/:id', {
params: {
id: id
},
description: descript
}).then(res => {
console.log(res);
}).catch(err => console.error(err));
}
I believe what you want is:
axios.put('http://localhost:5000/api/tasks/:id', {
description: descript
}, {
params: { id: id }
})
because the second parameter would be the data, and third as config: axios.put(uri, data[, config]).
function editTask(task) {
const id = task.parent().parent().attr('id');
const descript = task.parent().prev().text();
axios.put("http://localhost:5000/api/tasks/"+id, {
description: descript
}).then(res => {
console.log(res);
}).catch(err => console.error(err));
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With