Tell us what’s happening:
Guys Please i can’t pass this challenge it keeps saying database connection should be present. Anyone who’ve passed this challenge can you help me please? Thanks!
Your .env file isn’t hidden,
I can see your credentials and connect to the cluster if wanted.
[ It’s not terrible because Atlas has a lot of restrictions, but it would be easy to wipe out your databases ]
Did you test your connection?
This is how I tested:
First, comment out your main function, and write a simplified one:
async function main() {
const URI = process.env.MONGO_URI;// Declare MONGO_URI in your .env file
const client = new MongoClient(URI, { useNewUrlParser: true, useUnifiedTopology: true });
const a = await client.connect()
return a
}
main().then(client=>console.log(client)).catch(e=>console.log(e))