Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript User Authentication With Express and Mongo Improving the App with Custom Middleware Using MongoDB as a Session Store

Kevin Becerra
Kevin Becerra
14,243 Points

Cannot convert undefined or null to object

I'm trying to find out what exactly is causing the app to return me that error. The most I know is that it has something to do with the modules. When I have the most up-to-date ones I get that error but when I revert to the ones at the time of the lesson the app works. I just want to know what exactly was deprecated or changed in order to have the app working with the most recent modules.

Thanks in advance!

1 Answer

Nathan Boaldin
Nathan Boaldin
Courses Plus Student 12,545 Points

Just confirming that this fixes the problem. Change this code in your session middleware:

store: new MongoStore({ mongooseConnection: db })

to:

store: new MongoStore({ url: config.MONGODB_URI })

Where the code says "config.MONGODB_URI" place the actual url to your mongodb database.