Mini Reddit App

Well! It’s finally happened, the day has finally arrived. I have finally finished the project and I couldn’t be happier.

You can check out or review my project here:

Live Site
Repo

This project really took a lot of work and then some. I had to review a lot of lessons as I was feeling very lost at the beginning; but after many long hours in front of the computer, countless coffees and a few instances of almost punching a hole through my computer, I came through.
The one thing I was not able to fix was that I keep getting a CORS error on the first search using the Searchbar; after that it works just fine. If anyone has any idea how to fix that, all suggestions are welcomed!

1 Like

I know this is on older thread, but you’re getting a CORS error because the first request is: GET https://www.reddit.com/r/.json
Reddit has a redirect on that url, so you get a 301 moved permanently response without the json data you want. I don’t know if you’ll even see this, but this is why that happens:

useEffect(()=>{
dispatch(fetchSubredditPosts(currentSubreddit))
}, [currentSubreddit])

You’re using a useEffect hook with the dependency currentSubreddit, so when you dispatch your search, and set currentSubreddit=‘’, your effect triggers and dispatches fetchSubredditPosts(‘’). This means you send a request to reddit.com/r/.json, which gives you a 301 header in response.

Hope this helps you, or anyone else who might stumble on this. useEffect can be tricky!

1 Like

Hey! appreciate the feedback. I had already moved on from the project, but I’ll go back and fix that glitch! Thanks!!

1 Like