We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ea88985 commit 0dfba11Copy full SHA for 0dfba11
src/App.js
@@ -56,11 +56,13 @@ const App = () => {
56
57
// Delete Task
58
const deleteTask = async (id) => {
59
- await fetch(`http://localhost:5000/tasks/${id}`, {
+ const res = await fetch(`http://localhost:5000/tasks/${id}`, {
60
method: 'DELETE',
61
})
62
-
63
- setTasks(tasks.filter((task) => task.id !== id))
+ //We should control the response status to decide if we will change the state or not.
+ res.status === 200
64
+ ? setTasks(tasks.filter((task) => task.id !== id))
65
+ : alert('Error Deleting This Task')
66
}
67
68
// Toggle Reminder
0 commit comments