Advanced Node and Express - Registration of New Users not able to pass

Tell us what’s happening:

Your code so far

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36.

Challenge: undefined

Link to the challenge:
https://www.freecodecamp.org/learn/information-security-and-quality-assurance/advanced-node-and-express/registration-of-new-users

Hello and welcome to the forum :grin:!

Please, provide the code that you’ve written so far so we can help you, otherwise we cannot know what the problem is :slight_smile:.

Use glitch.com and/or github.com. If using glitch, remember to share the Code view instead of the Project or Live App.

The problem is that you’re not selecting a database, hence the routes fail. Please, always check the glitch console logs to see if there are errors, try to solve them and if you still need help, come to the forum :slight_smile:, that way you’ll learn more.

Fix:

Replace db.collection with db.db("database_name").collection:

// This is part of the code:
db.db("testdb").collection('users').findOne({ username: req.body.username }, function (err, user) {
// Here goes the rest of the code
});

db_name is the name of the database you’ve setup on the mongodb atlas or mlab.

I am not able to understand what actually is the problem in my code and has been trying every hack mentioned but no luck

very thankful for your reply but i am still not able to pass the challenge event after making the changes you mentioned. Can you please tell me if there is still something missing in my code -

i have rewinded my project a little bit so it may be a little different from what you saw earlier if thats not a problem

I am still not able to understand what is the problem and has been stuck in this challenge for the past two days. Can you suggest what may be wrong in the code.

I am new to this this challenge and any help regarding the code would be appreciated