Closed niftylettuce closed 8 years ago
You can search in closed issues. He make this with Promises. Short answer: Just catch the error, like a Promise. (.then().catch();)
@michaeljota how can we await
a db connection before starting our app?
IDK. But, I see something like like that as a title of some close issue.
Here's how I did it (I'm using Koa):
// connect to the db
connect(config.db).then(db => {
console.log(`MongoDB connected to ${config.db}`);
}).catch(err => {
console.error(err);
process.exit(1);
});
// initialize the app
const app = new Koa();
How are these errors handled? I'm coming from Mongoose