Need help debugging my blog

I started this blog but unfortunately got stuck. After I register a user I click on sign in, fill out credentials, but it returns an error. Just wondering what it could be. I was reading from Greg Lim’s codealong book on Express, Mongo, and Node.

Here is the error I get. It happens after I sign in on the login page:

TypeError: Cannot destructure property username of ‘undefined’ or ‘null’.
at module.exports (C:\Users\alexander.ross\Documents\jsdev\blog\controllers\loginUser.js:5:11)
at Layer.handle [as handle_request] (C:\Users\alexander.ross\Documents\jsdev\blog\node_modules\express\lib\router\layer.js:95:5)
at next (C:\Users\alexander.ross\Documents\jsdev\blog\node_modules\express\lib\router\route.js:137:13)
at module.exports (C:\Users\alexander.ross\Documents\jsdev\blog\middleware\redirectIfAuthenticatedMiddleware.js:5:5)
at Layer.handle [as handle_request] (C:\Users\alexander.ross\Documents\jsdev\blog\node_modules\express\lib\router\layer.js:95:5)
at next (C:\Users\alexander.ross\Documents\jsdev\blog\node_modules\express\lib\router\route.js:137:13)
at Route.dispatch (C:\Users\alexander.ross\Documents\jsdev\blog\node_modules\express\lib\router\route.js:112:3)
at Layer.handle [as handle_request] (C:\Users\alexander.ross\Documents\jsdev\blog\node_modules\express\lib\router\layer.js:95:5)
at C:\Users\alexander.ross\Documents\jsdev\blog\node_modules\express\lib\router\index.js:281:22
at Function.process_params (C:\Users\alexander.ross\Documents\jsdev\blog\node_modules\express\lib\router\index.js:335:12)
at next (C:\Users\alexander.ross\Documents\jsdev\blog\node_modules\express\lib\router\index.js:275:10)
at session (C:\Users\alexander.ross\Documents\jsdev\blog\node_modules\express-session\index.js:182:7)
at Layer.handle [as handle_request] (C:\Users\alexander.ross\Documents\jsdev\blog\node_modules\express\lib\router\layer.js:95:5)
at trim_prefix (C:\Users\alexander.ross\Documents\jsdev\blog\node_modules\express\lib\router\index.js:317:13)
at C:\Users\alexander.ross\Documents\jsdev\blog\node_modules\express\lib\router\index.js:284:7
at Function.process_params

Does the top line indicate that a user was never created when I first registered one? If so, what could be the problem? Let me know if any of y’all have seen an error like this before. Thanks ahead of time for your help.

Please try to be as specific as possible when you request our help. If you are represented with an error, please post that error. It’s a lot easier for us to tell you what’s going on if we don’t have to dive into all of your code and hopefully find the issue. We’ll most likely end up with a lot of different issues and tips that aren’t even related to the problem you’re facing.

The more specific you can be to us, the faster we’ll be able to help you out :slight_smile:

1 Like