1 00:00:01,110 --> 00:00:05,730 Let's take a look at a solution, the first thing we're going to do is inspect the hook itself and try 2 00:00:05,730 --> 00:00:07,650 to get a better idea of how it operates. 3 00:00:08,180 --> 00:00:11,450 So inside of here, we are declaring a piece of state called posts. 4 00:00:11,820 --> 00:00:12,810 We also get the setar. 5 00:00:13,320 --> 00:00:15,470 We then have a U.S. fact function call. 6 00:00:15,660 --> 00:00:19,080 And inside there is some code to make a request out to this outside API. 7 00:00:19,890 --> 00:00:23,850 This time around, we are not making use of that axios module that we've been using throughout the course. 8 00:00:24,090 --> 00:00:27,750 Instead, we are using a function called Fetch to go and get some data for us. 9 00:00:28,620 --> 00:00:33,500 After fetching some data from the API, we then use that data to update our post piece of state. 10 00:00:34,230 --> 00:00:38,700 So chances are that post is going to be an array of objects or something like that. 11 00:00:39,300 --> 00:00:42,600 We then ultimately return that array of objects from this hook. 12 00:00:43,760 --> 00:00:50,120 Let's now go over to our aptness file, we will import U.S. post, call it, and then see if it actually 13 00:00:50,120 --> 00:00:51,740 does give us back an array of objects. 14 00:00:52,850 --> 00:00:55,880 So inside of my aptness file, I'm going to import. 15 00:00:57,200 --> 00:00:58,280 Use posts. 16 00:01:02,470 --> 00:01:03,940 Then at the top of the component. 17 00:01:05,400 --> 00:01:10,710 I'm going to define a variable called post, and that's going to be the result of calling use posts 18 00:01:10,710 --> 00:01:11,250 like so. 19 00:01:12,560 --> 00:01:14,300 And sure enough, looks like that worked. 20 00:01:14,540 --> 00:01:19,100 It's all we really had to do, we just had to understand that U.S. post was going to make a request 21 00:01:19,100 --> 00:01:21,560 for us, return an array of objects. 22 00:01:21,560 --> 00:01:24,770 And once we understood that, we can very easily use it inside of another component. 23 00:01:26,210 --> 00:01:28,250 Naturally, I'm going to make sure I check my solution. 24 00:01:31,150 --> 00:01:32,530 And after running those tests. 25 00:01:34,220 --> 00:01:34,770 There we go. 26 00:01:34,930 --> 00:01:36,910 Looks like it worked out OK. 27 00:01:36,950 --> 00:01:39,310 So let's take a pause right here and continue in just a moment.