const { MongoClient, ServerApiVersion, ObjectId } = require('mongodb');
const uri = mongodb srv://{processs.env.DB_USER}:${process.env.DB_PASS}@cluster0.az3oh.mongodb.net/myFirstDatabase?retryWrites=true&w=majority
;
const client = new MongoClient(uri, { useNewUrlParser: true, useUnifiedTopology: true, serverApi: ServerApiVersion.v1 });
CodePudding user response:
I think you're confused with the mongodb account password and user password. You should use a user password, not an account password. That was the reason for my case.
CodePudding user response:
I think you using wrong username and password. 1. Open Atlas, 2. Go to "Database Access", 3. Click edit on the Database user, 4. Choose password for authentication method, 5. Click edit password, 6.Click show in the password field, 7.Click autogenerated secure password, 8.Don't press copy button for copy, but use manual selection via mouse and copy the text via keyboard command, 9.Click update user below
const uri = mongodb srv://[username]:<password>@cluster0.yfafd.mongodb.net/myFirstDatabase?retryWrites=true&w=majority
;