findbyid and delete mongoose await code example
Example: findbyid and delete mongoose await
Subscriber.findByIdAndRemove(subscriberId)
.then(() => {
res.locals.redirect = "/subscribers";
next();
})
.catch(error => {
console.log(`Error deleting subscriber by ID: ${error.message}`);
next();
});