In the last section we started putting together our post reducer. 2
We decided the two pieces of application state one for the list of blog posts and one for the currently 3
selected posts that were viewing. 4
Again remember that we have a separate piece of state for each one in this section. 5
We're going to finish wiring up the blog posts from douceur. 6
We already have our fecche post type set up here. 7
Important at the top and we've already set the key statement right here as well. 8
We have to make sure that our in the case so we have a fetch posts action flowing through here. 9
All we need to do is return our application state. 10
That includes the list of blog posts from that action. 11
Now before we write that line of code two reminders ferse with redox promise and actually shows the 12
data that we care about is going to be available on action. 13
Payload data and second are douceur needs to return a new object whenever we return our state. 14
So with those two reminders in our head let's go ahead and get the shot. 15
We'll say return and then we'll make a new object. 16
You are going to say this is a distinctly new version of our state and will say just go ahead and take 17
whatever our current state is and also add on all action payload data. 18
So new objects take whatever our current state is and then add in this property. 19
All of our blog posts as action payload data. 20
So this is the response from the API right here. 21
OK. 22
So we've got our ACSM creator. 23
We got our action. 24
We've got our reducer all wired up. 25
This is all starting to look pretty good. 26
I think we're starting to come along here. 27
I mean to save this and just to make sure that we don't have any blatant typos in here I'm going to 28
save all my files and just go ahead and refresh in the browser and make sure I don't have any errors 29
popping up here. 30
Do you have any errors of mutants that you might have a typo somewhere in here. 31
You know just go ahead and usual debug and process. 32
OK. 33
So we've got our data layer all wired up here. 34
So what's next. 35
We need to think about when to fetch our list of blog posts we need to make sure that the action creator 36
is actually being called and that the network request is actually being made. 37
And so the question is really when do we make that. 38
Well obviously we want to do it whenever the user looks at the index page but where are we going to 39
place that code. 40
Let's go ahead and answer that question in the next section.