Answer the question
In order to leave comments, you need to log in
How to properly catch connection errors to mongoDB through mongoose?
Right now I'm trying to handle errors like this:
export function connection() {
mongoose.connect(`mongodb://${config.db.host}:${config.db.port}/${config.db.name}`, (err) => {
err ? console.error(error) : console.log('Server has been connected to MongoDB');
});
}
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