To get Mongoose connect error with Node, we call connect
with a callback as the 2nd argument.
For instance, we write
mongoose.connect("mongodb://localhost/dbname", (err) => {
if (err) {
throw err;
}
});
to call connect
with a callback as the 2nd argument.
We get connection errors from err
if there’s any.