MongoDB with Node, SyntaxError: Invalid shorthand property initializer


i am trying to connect to mongoDB on Node with express

MongoClient.connect(process.env.HOTELS_DB, {useNewUrlParser = false})

I getting the fallowing error


MongoClient.connect(process.env.HOTELS_DB, {useNewUrlParser = true})

SyntaxError: Invalid shorthand property initializer

What am i doing wrong here


You’re using = in the place of : you need to use colon in JavaScript object like key: value

MongoClient.connect(process.env.HOTELS_DB, {useNewUrlParser : false})

Answered By – kiran

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published