Let's take a look at a solution, the first thing we're going to do is inspect the hook itself and try
to get a better idea of how it operates.
So inside of here, we are declaring a piece of state called posts.
We also get the setar.
We then have a U.S. fact function call.
And inside there is some code to make a request out to this outside API.
This time around, we are not making use of that axios module that we've been using throughout the course.
Instead, we are using a function called Fetch to go and get some data for us.
After fetching some data from the API, we then use that data to update our post piece of state.
So chances are that post is going to be an array of objects or something like that.
We then ultimately return that array of objects from this hook.
Let's now go over to our aptness file, we will import U.S. post, call it, and then see if it actually
does give us back an array of objects.
So inside of my aptness file, I'm going to import.
Use posts.
Then at the top of the component.
I'm going to define a variable called post, and that's going to be the result of calling use posts
like so.
And sure enough, looks like that worked.
It's all we really had to do, we just had to understand that U.S. post was going to make a request
for us, return an array of objects.
And once we understood that, we can very easily use it inside of another component.
Naturally, I'm going to make sure I check my solution.
And after running those tests.
There we go.
Looks like it worked out OK.
So let's take a pause right here and continue in just a moment.