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

前端 未结 21 2921
既然无缘
既然无缘 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:26

    const conn = await mongoose.connect(process.env.MONGO_URI, {
          useNewUrlParser: true,
          useUnifiedTopology: true,
          useCreateIndex: true
        })
    

    Always put useNewUrlParser:true before putting the useUnifiedTopology:true, and then the rest.

提交回复
热议问题