Hi Basir
I am working through your Build Ecommerce website like Amazon (React, Node & MongoDB) course in Udemy and am encountering an error in lesson 41 – Delete Products (old Amazona).
I am receiving a 500 Internal Server Error and depending on what changes I made to my code, a No Token error – Note: It does return a token with the 500 error. I am not sure what I’m doing wrong as all my code looks correct when compared to the lesson notes and the git repositories of other students, do you have any ideas that may fix these errors in my code?
I look forward to hearing your ideas and to leaving a fantastic review once I have completed the course.
thanks!
Best Regards
Michelle
MB Posted new comment July 11, 2023

I found my error .. for anyone else having a similar problem, in ProductRouter.js (line 88) change:
const deleteProduct = await product.remove();
to:
const deleteProduct = await Product.findByIdAndRemove(req.params.id);