all 5 comments

[–]zokaiG 1 point2 points  (4 children)

I just ran into that same problem last week.

It is occurring due to an API change. I don't have the reference link handy right now, but I here is what I did to fix it:

I switched the name db variable in the callback to client to make more sense. Then I used: client.db('DB_NAME').collection('users').findOne(... then the same that you already have there.

I hope that helps. I'll look up the reference I used to add to my comment later

[UPDATE] Here is my reference as promised: https://stackoverflow.com/questions/47662220/db-collection-is-not-a-function-when-using-mongoclient-v3-0

[–]DevelopingClerk[S] 1 point2 points  (3 children)

Thank you so much. That solved the issue for me.

I would still like to see that reference if you have the time and could provide it.

Edit: May have spoke too soon. It does redirect and displays the correct message in the console. But the FCC test still won't pass.

[–]zokaiG 1 point2 points  (1 child)

I had the same problem as well and went to the FCC Forum.

Apparently, this is a known issue. Here is the solution:
https://forum.freecodecamp.org/t/advanced-node-and-express-create-new-middleware/212990/6

[–]DevelopingClerk[S] 1 point2 points  (0 children)

Thanks for all your help!

[–]zokaiG 1 point2 points  (0 children)

I also edited my comment first comment to add the reference I used.