Cannot remove data on MongoDB (MERN stack)

Hi @Kushagra_Kesav,

Thank you. I’ve tried your answer but it didn’t work as well as there was no change on the error log. I’ve also tried req.params but still stucked up.

I’ve modified taskController.js removeTask function code:

const removeTask = (req, res) => {
    const { _id } = req.body;
    const taskId = _id ? mongoose.Types.ObjectId(_id) : new mongoose.Types.ObjectId();

    taskModel.findByIdAndDelete({ _id: taskId })
...

Now I can see the ID on the request URL but still receiving Internal Server Error

Task ID to remove: 662e7dc365cc6fb9a0e14ed7 [Task.jsx:14]
XHR OPTIONS http://localhost:8000/api/task/removeTask?_id=662e7dc365cc6fb9a0e14ed7[HTTP/1.1 204 No Content 2ms]
XHR GET http://localhost:8000/api/task/removeTask?_id=662e7dc365cc6fb9a0e14ed7[HTTP/1.1 500 Internal Server Error 2ms]