Categories
JavaScript Answers

How to connect to MongoDB and authenticate with Node.js?

Spread the love

To connect to MongoDB and authenticate with Node.js, we call the authenticate method.

For instance, we write

Db.authenticate(user, password, (err, res) => {
  // callback
});

to call authenticate with the user username and password to connect to the database with the credentials.

We get the result from the callback.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *