Reddit Client (Help)

Hello world, I am currently stuck in Reddit Client project? I don’t know how to get data from Reddit and display it. Can anyone shine some light on my question?

How can I approach this part?

My progress so far just finished the NavBar.

Here’s in GitHub repo.

Hey @eugenegoh,

Looks like you’re on the right track with with the async functions in your useEffect. But instead of fetching individual articles, why not try grabbing every article from a collection and then mapping over them to display each one?

Two big ah-ha moments for me were that just about every reddit.com page can return a json object. So if you wanted every article in, say the WallStreetBets collection, you would just need to fetch from www.reddit.com/r/wallstreetbets.json.

The second thing I struggled with was all the nesting (.children, .data, etc) to actually get to the relevant array. But from looking at your code, I’d say you’re pretty close.

Oh and one more thing that helped me big time in this project is the .map() method. It took me an embarrassingly long time and hours of trawling youtube to figure out you can just plop something like this in the middle of your JSX:

{articles.map((article) => {
    const {thumbnail, title, id} = article.data;
    return (
        <div key={id}>
            <img src={thumbnail} />
            <h3>{title}</h3>
        <div/>
    )
 }

Hope that helps!