mongoose.connect(), first argument should be String, received undefined

前端 未结 21 2952
既然无缘
既然无缘 2021-02-12 15:55

I am trying to set the test database for the testing purpose, but its not working.

I am trying to connect to mongodb using mongoose, but finding problem in connection er

21条回答
  •  遥遥无期
    2021-02-12 16:30

    This is what solved my problem. Happy Coding!

    // Connect to MongoDB
        mongoose.connect('mongodb://yourusername:yourpassword@ds121825.mlab.com:11025/yourmongodb', {useNewUrlParser: true});
        mongoose.connection.once('open', function(){
          console.log('Conection has been made!');
        }).on('error', function(error){
            console.log('Error is: ', error);
        });
    

提交回复
热议问题