i'm setting up mongoDB and i keep getting error Error: Invalid schema, expected mongodb or mongodb+srv
please help me,
const mongoose = require('mongoose')
const connectionString = "mongodb + srv://PLACEHOLDER:<PLACEHOLDER>@cluster0.czgrzdd.mongodb.net/TASK-MANAGER?retryWrites=true&w=majority&appName=Cluster0"
mongoose.connect(connectionString).then(() => console.log('connected to the db')).catch((err) => console.log(err))`
the placeholders are from me not the code i don't want to leak my password and username but i already looked for problems and couldn't find any
I have no idea how to fix this or where to start please help me
Here is what I used to successfully connect to a MongoDB database. I've confirmed this works for both locally hosted and MongoDB Atlas
Also, make note to remove the space between mongodb and + and put in placeholder for where your password should be. What you provided should now look like:
If you're still having trouble, try uncommenting the
mongoose.set( 'debug', true );and see what your console tells you.Hope this helps!