I have an app developed using MEAN stack. I am getting the following error
(node:4920) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): MongoError: failed to connect to server [ds047865.mongolab.com:47865] on first connect [Mon goError: connect ECONNREFUSED 130.211.211.211:47865]
(node:4920) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code
here is my code:
var mongoose = require('mongoose');
var validator = require('mongoose-unique-validator');
var nodemailer = require('nodemailer');
mongoose.connect('mongodb://naresh:naresh@ds249025.mlab.com:49025/languageapp', { useMongoClient: true });
var db = mongoose.connection;
db.on('connect', function () { console.log('connected'); });
var userSchema = new mongoose.Schema({
userName: { type: String, required: true, index: true, unique: true },
userEmail: { type: String, required: true, index: true, unique: true },
userPass: { type: String, required: true },
Date: { type: String, default: Date.now() },
userResult: String
});
var questionSchema = new mongoose.Schema({
question: { type: String, unique: true },
op1: String,
op2: String,
op3: String,
op4: String,
rightAnswer: String,
questionType: String,
questionID: String,
quizTopic: String,
CreatedAt: { type: String, default: Date.now() }
});
var resultSchema = new mongoose.Schema({
userID: String,
userName: String,
userMatriculation: String,
userEmail: String,
quizTopic: String,
userResult: String,
date: { type: String, default: Date.now() }
});
userSchema.plugin(validator);
var User = mongoose.model('Users', userSchema);
var Question = mongoose.model('Questions', questionSchema);
var Result = mongoose.model('Results', resultSchema);
I am not using any promises though am getting these errors.