Hello there, this advanced node challenge have to conect with database to implement the serialization of a passport user but the connection is always failing to connect
myDB(async client => {
const myDataBase = await client.db('database').collection('users');
// Be sure to change the title
app.route('/').get((req, res) => {
// Change the response to render the Pug template
res.render('index', {
title: 'Connected to Database',
message: 'Please login'
});
});
// Serialization and deserialization here...
passport.serializeUser((user, done) => {
done(null, user._id);
});
passport.deserializeUser((id, done) => {
myDataBase.findOne({ _id: new ObjectID(id) }, (err, doc) => {
done(null, doc);
});
});
// Be sure to add this...
}).catch((e) => {
app.route('/').get((req, res) => {
res.render('index', { title: e, message: 'Unable to login' });
});
});
Here’s the link to the repl
The error in console is type error of “split”
But never used the split in entire code