TypeError: 'connect' only accepts a callback

Viewed 4346

when I try node index.js my error comes with TypeError: 'connect' only accepts a callback, then I'm confused about how to solve this problem. The error goes to mongo_client.js:165:11

I did a tutorial about how to connect to mongodb with Nodejs but, I found a problem that ppl never had since now

const mongodb = require('mongodb');
const MongoClient = mongodb.MongoClient();
const url = 'mongodb://localhost:27107/testedmtdev';

MongoClient.connect(url, function(err, client){
    if(err){
        console.log('Unable to connect to the Mongodb server. Error : ', err);
    } else {
app.listen(3000, ()=>{
            console.log('Connected to mongodb, webservice running on port 3000');
        })
    }
});

I expect the output of 'Connected to mongodb, webservice running on port 3000'

1 Answers
Related