Throw new error_1.MongoAPIError('URI must contain host name, domain name and tld');
Hi everyone, I'm getting an error while connecting my backend to mongodb. I'm a student and I'm learning full stack while developing a project, but I'm getting the above error.
I'm trying to connect my mongodb to my backend server but it won't happen and instead it sends me the error mentioned above.
const connect = async () => { try{ await mongoose.connect('mongodb+srv://rahulghatge166:Rahul@[email protected]/Booking?retryWrites=true&w=majority'); console.log('Connected to MongoDb') }catch(error) { throw error } } mongoose.connection.on('disconnected', () => { console.log('mongoDb disconnected') }) mongoose.connection.on('connected',() => { console.log('mongoDb is connected') })
Your password has a special character,
@
. You need to encode it as@
.Change the code to: