project_mern_memories
project_mern_memories copied to clipboard
Posts from the database won't load, but I can create a new one just fine.
I have an issue where my posts from the database won't load but if I create a new post, the new one's will show up just fine. If I then refresh the page, the posts disappear again and I just get my loading screen. Any new posts are sent to my database with no issue, so I know my DB connection is OK. I started getting status code 404 whenever I reload the page. Anybody else facing something similar? Any idea how to fix it?
@benitoito Check out your mongo DB schema first and your upload, download, mongo DB actual data as well. If mongo DB's data all set up correctly in a mongo DB cloud it maybe a problem with getting data from a server.
I'm having a similar issue, if anybody solves it let me know @benitoito
Solved for me! Actually it was just a silly mistake. in App.js in the useEffect hook, I wrote: dispatch(getPosts); instead of dispatch(getPosts());
Reviewed the first tutorial until I saw it, I hope it's the same thing for you!
I also had same issue. Fixed by adding the ! in !posts.length in the posts component. then they displayed.
I am facing the same issue even when doing what you both did @hafeed06 and @imjord. I can see that the post does get created in my MongoDB cluster but doesn't seem to be retrieved on the front end. Any ideas what the issue might be?
Update: I solved the issue by making sure the useEffect(() function is under const dispatch = useDispatch();