Advanced Node and Express - Logging a User Out

Tell us what’s happening:
The previous assignment passed. Below is the only new code that I added per the new assignment. What am I doing wrong here? I’ve also included the console error message.
Screen Shot 2023-01-28 at 10.24.55 PM


  app.route('/logout').get((req, res) => {
      req.logout();
      res.redirect('/');
    });

  app.use((req, res, next) => {
    res.status(404)
      .type('text')
      .send('Not Found');
  });
  

Your project link(s)

solution: boilerplate-advancednode - Replit

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36

Challenge: Advanced Node and Express - Logging a User Out

Link to the challenge:

Looks like the error is being caused by this line in the server.js file

  app.route('/profile').get(ensureAuthenticated, {username: req.user.username}, (req, res) => {
    res.render('profile');
  })

It’s the req.user.username specifically, I think.

On a side note, that advanced Node and Express section isn’t necessary for completing the projects in the QA certificate. If you get to the Information Security Certificate, you need to use socketio for one of the projects. So if that section is causing you problems, it’s probably worth skipping - that whole section is 90% just copying and pasting code anyway.

Thanks. I made the req.user.username object the 2nd argument in the res.render statement, and that worked. Thank you for pointing me in the right direction.

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