I have tried this
mongoose.connect('mongodb://localhost/ninjago', { useNewUrlParser: true });
to connect mongodb on nodejs and working fine.
But when i try to create data, it gives this error
"(node:18194) UnhandledPromiseRejectionWarning: MongoError: command insert requires authentication"
can anyone help me out? i am using ubuntu 18.04.
Specify the username and password in your MongoDB URI. Something like:
mongoose.connect('mongodb://user:pass@localhost/ninjago', …
Reference:
Check if the database name exist and specify the port
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With