Unable to connect to MongoDB CLoud atlas on the custom database. Need to have documentation on it
I am getting 500 error on console. Please help me with this asap. Thank you
function getByEmail(email, callback) {
const MongoClient = require('mongodb').MongoClient;
const uri = `mongodb://${
configuration.user}:${
configuration.pass}@database-bok6g.gcp.mongodb.net/${db.name}`;
const client = new MongoClient(uri, { useNewUrlParser: true });
client.connect(uri, function (db) {
const collection = client.db("database").collection("users");
collection.findOne({ email: email }, function (err, user) {
if (err) return callback(err);
return callback(null, {
user_id: user._id.toString(),
email: user.email
});
});
});
}