#Implement the Serialization of a Passport User

Tell us what’s happening:
Describe your issue in detail here.
Hi there.

I think I am connected correctly to MongDB but I don’t know how to solve the following error. Somebody please help me :slight_smile: thanks in advance

Your code so far
// #5
myDB(async (client) => {
const myDataBase = await client.db(‘database’).collection(‘users’);

app.route(’/’).get((req, res) => {
res.render(‘pug’, {
title: ‘Connected to Database’,
message: ‘Please login’
});
});

passport.serializeUser((user, done) => {
done(null, user._id);
});
passport.deserializeUser((id, done) => {
myDataBase.findOne({ _id: new ObjectID(id) }, (err, doc) => {
done(null, doc);
});
});
}).catch((e) => {
app.route(’/’).get((req, res) => {
res.render(‘pug’, { title: e, message: ‘Unable to login’ });
});
}).catch((e) => {
app.route(’/’).get((req, res) => {
res.render(‘pug’, { title: e, message: ‘Unable to login’ });
});
});

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36

Challenge: Implement the Serialization of a Passport User

Link to the challenge:

Can you show the whole code?

I had the same issue. here is my replit server.js code: https://replit.com/@Luderio/boilerplate-advancednode#server.js

I am encounter this error:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.