skip to Main Content

Mongodb – MongooseError: Model.findOne() no longer accepts a callback in backend log

import express from"express" import cors from "cors" import mongoose from "mongoose" import bodyParser from'body-parser' // const {Schema} = mongoose; const app = express() app.use(bodyParser.json()) app.use(bodyParser.urlencoded({extended: true})) app.use(cors()) await mongoose.connect('mongodb://127.0.0.1:27017/loginRegisterDB',{ useNewUrlParser: true, useUnifiedTopology: true },) .then(() => console.log( "connected")) .catch((err) =>…

VIEW QUESTION

Can Javascript connect to mongodb?

I got error "throw new MongooseError('Mongoose.prototype.connect() no longer accepts a callback');" const mogoURI = "mongodb://localhost:27017/?directConnection=true"; const connectToMongo = ()=>{ mongoose.connect(mogoURI,()=>{ console.log("Connected to Mongo Successfully"); }) } module.exports = connectToMongo;```

VIEW QUESTION
Back To Top
Search