Reputation: 11
MongooseError: The uri
parameter to openUri()
must be a string, got "undefined". Make sure the first parameter to mongoose.connect()
or mongoose.createConnection()
is a string. at _createMongoClient
not able to connect mongodb Some code
my env file
connecting the mongo db
Upvotes: 1
Views: 644
Reputation: 454
Couple of points:
process.env.ENV_VARIABLE_NAME
?process.env
using some library like dotenvprocess.env
under the name of the variable. eg..env file
MONGODB_URI=mongo+srv://Aditya........
******
. You have to remove the asterisks and replace them with the password you generated manually or had MongoDB generate automatically while creating the database. If you don't have the password which can only be seen once, go to database user settings, add another user or edit the current user to update the password and then copy it once and store it somewhereUpvotes: 0