Closed ghost closed 3 years ago
@tungandy Did you find a problem?
I have the same problem.
I'm having that issue now.
Did anyone find a solution to this? I'm getting the same problem
@elysenko thanks for noting. I will try to reproduce the problem or then explain or solve the issue.
@elysenko I ran the 2-end
codebase and was able to retrieve email address from my database.
Can you try running the 2-end
codebase? Do you get the same error?
If you don't get an error when running 2-end
, then there's probably an issue in the codebase you are running as you work through Chapter 2.
If you still get an error when running 2-end
, then there's probably a problem in the connection to your database.
When I run the 2-end code I get the same error...
In checking the connection to my db, I confirmed that running yarn dev-express
does create a users
collection in my db, so maybe that rules out a connection issue?
@elysenko thanks for testing.
Could you create a public repo with the exact code that is giving you an error? We will run the code and look for the problem.
@elysenko did you figure out the problem?
not yet. https://github.com/elysenko/2-begin
Thanks, I will test and see if I can reproduce the problem.
@klyburke any word?
@elysenko I ran your code with my own .env
file and did not have a problem. The app loaded as expected with the email address from my database.
There are a few potential problems you can check:
(1) Does your MONGO_URL
have the correct name of your database? Recall that MONGO_URL has the following format
mongodb+srv://<username>:<password>@cluster0-eoobe.mongodb.net/<db>?retryWrites=true
db
is the name of your database. I found that if this name is incorrect, you will see TypeError: Cannot read property 'email' of null
.
(2) It's possible that MongoDB Atlas is not properly connecting to your IP address. Atlas has a troubleshooting guide: https://docs.atlas.mongodb.com/troubleshoot-connection/
(3) You may have an error in the user document you created. Check that your document has these fields with the proper type (e.g. Date, String):
Alright. My issue was the document created on the db. The textbook doesn't have you create it until after you run yarn dev-express
. You get the error when there is no document created. Thanks for your help!
Hello,
I am in the middle of Chapter 2 and just created my document on MongoDB Atlas. Following the instructions I am getting the error "Unhandled Rejection (TypeError): Cannot read property 'email' of null" when trying the get the email from the database.
Any ideas what has gone wrong?
Thanks. Andy
Click to see Hill for issue #203
created by Async