You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
app.delete('/managetask/:id',async(req,res)=>{const{ id }=req.params;// await Task.findOneAndDelete(id);console.log(id);res.redirect('/managetask');});
from the above snippet you got the id from the request parameter and performed a delete operation . It is correct but for the view i think you should ensure you pass the right id to the "/managetask" route after clicking the button on the modal . The redirect url will show the update after deletion.
Hi,
I am trying to implement inline delete on a table using a modal. Here is my code.
<% for (let ta of task) { %>
<%= ta.taskID %>
<%= ta.taskName %>
<%= ta.taskType %>
Delete
Are you sure you want to delete <%= ta.taskName %>?
×
CONFIRM DELETE
<% } %>
here is my route:
app.delete('/managetask/:id', async (req, res) => {
const { id } = req.params;
// await Task.findOneAndDelete(id);
console.log(id);
res.redirect('/managetask');
});
I tried logging the id and it is showing the id of the first item on the table instead of the actual item am trying to delete.
please help!
The text was updated successfully, but these errors were encountered: