Answer the question
In order to leave comments, you need to log in
Error handling when Mongo crashes - how to implement?
How to make an error output when the base has fallen? At the moment, everything is just spinning for me, and then the entire server crashes if there is a request to Monga, and Monga itself is not running. I am using Mongoose
My Controller:
exports.secret = function (req, res) {
User.findById(req.user.sub, function (err, user) {
if (err) {
res.send('DB is broken')
return
}
if (user) {
res.send({
eee: req.user,
hi: 'SECRET test authorization of registered user'
})
} else {
res.send('user not found')
}
})
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question