Incomplete key value pair for option remote mongod

2019-08-23 10:24发布

问题:

I'm trying to deploy my local node mongoDB app to Heroku. Everything is working fine on my local machine, no errors.

First thing I'm trying to do is to connect to a database on mlab. It seen very straight forward but I get this error:

err { MongoParseError: Incomplete key value pair for option
  name: 'MongoParseError',
  message: 'Incomplete key value pair for option',
  [Symbol(mongoErrorContextSymbol)]: {} }

My code looks like this:

    var mongoose = require('mongoose');

    const options = {
            useNewUrlParser: true
          };

    mongoose.connect("mongodb://username:password@xxxxx.mlab.com:39251/nameodDB",options).then(
   ()=>{
      console.log("connected to mongoDB")},
   (err)=>{
       console.log("err",err);
 });