bryantheastronaut / mernCommentBox

A Tutorial on creating a MERN Stack App from the Facebook Comment React Tutorial
https://medium.com/@bryantheastronaut/react-getting-started-the-mern-stack-tutorial-feat-es6-de1a2886be50
248 stars 92 forks source link

issues connecting to mongolab #22

Closed dummyuserWLA closed 6 years ago

dummyuserWLA commented 6 years ago

I wasn't able to connect to mongolab using the syntax/set-up instructions in the readme...

the 'GET' route (and 'POST') to http://localhost:3001/api/comments in postman was timing out due to failed connection

for those of you out there trying to replicate this project and encountering similar issues, in server.js, replace this code: // db config var mongoDB = 'mongodb://:@ds257485.mlab.com:57485/merncommentbox'; mongoose.connect(mongoDB, { useMongoClient: true }) var db = mongoose.connection; db.on('error', console.error.bind(console, 'MongoDB connection error:'));

with: mongoose.Promise = global.Promise; mongoose.connect( process.env.MONGODB_URI || "mongodb://localhost/", { useMongoClient: true } );

bryantheastronaut commented 6 years ago

Thanks for the heads up. I can try to get to updating this, or if you have it working and want to open a PR that would be appreciated!