require('dotenv').config(); const mongoose = require('mongoose'); const uri = `mongodb+srv://${process.env.MONGODBUSER}:${process.env.MONGODBPASS}@${process.env.MONGODBCLUSTER}/${process.env.DATABASE}?retryWrites=true&w=majority` mongoose.connect(uri, { useNewUrlParser: true, useUnifiedTopology: true }).then(() => { console.log(`Connected to the database`); }).catch((error) => { console.log(`Failed to connect to the database`); console.log(error); });