Deleting The Current User | How User Can Delete Him / Her For API | API Development Course 2023

preview_player
Показать описание
Deleting the Current User

This route uses the findById and remove methods of the Mongoose Model class to find and delete the user from the database. It also includes error handling to send appropriate responses to the client in case of any failures.

To use this route, a client would need to send a DELETE request to the API with the user's ID in the URL, like this:

Deleting the Current User | How User Can Delete Him / Her For API | API Development Course 2023

For any help related to code Errors, Please Join the Discord server

===================
HOSTING
++++++++++++++++++++

Follow Me:

Workout Video:
Рекомендации по теме
Комментарии
Автор

but I don't understand it, it's just like you did, 1000 checked but the user no delete at the end. 204 ok but not delete, why?
and I noticed that I have one more header than you

joseantonioapariciogallego
Автор

correct one:
await User.findByIdAndUpdate(req. user .id, { active: false });

instead of:
await User.findByIdAndUpdate(req. body .id, { active: false });

martinc
Автор

Daulat, this doesn't work. All users remain as ACTIVE

martinc