1 00:00:00,890 --> 00:00:05,450 All right, my friends, let's take a look at a solution to the big thing to keep in mind here is that 2 00:00:05,450 --> 00:00:08,720 we are making a network request from inside of a use effect function. 3 00:00:09,020 --> 00:00:14,150 Network requests are always asynchronous in nature, so we probably want to make use of that async O8 4 00:00:14,180 --> 00:00:19,260 syntax here, but we cannot use a wait directly inside of a U.S. fact function. 5 00:00:19,610 --> 00:00:24,650 So in other words, we cannot mark that function right there with a sink not allowed. 6 00:00:24,890 --> 00:00:26,440 And if we do that, we'll end up with an error. 7 00:00:27,230 --> 00:00:31,940 So instead, one pattern we can use is to define an extra function inside of use effect. 8 00:00:32,420 --> 00:00:34,970 Maybe we can call it something like fetch users. 9 00:00:37,190 --> 00:00:40,160 And we are allowed to mark that function as async. 10 00:00:41,720 --> 00:00:46,910 Right after defining that function, we can then call it ourselves manually now inside there, we can 11 00:00:46,910 --> 00:00:49,730 place as much async, await logic as we wish. 12 00:00:50,330 --> 00:00:53,720 So in this case, I'm going to get back some data. 13 00:00:54,560 --> 00:00:59,120 By making a request with Axios to that URL like so. 14 00:01:00,690 --> 00:01:04,320 Don't forget to mark the request right there with O8. 15 00:01:05,300 --> 00:01:10,010 And then in addition, recall that whenever we make a request with Axios, we get back a response object 16 00:01:10,310 --> 00:01:12,970 and one property of that response object is data. 17 00:01:13,550 --> 00:01:17,780 So we only care about the data in this case, which is why we are structuring off the data property. 18 00:01:19,440 --> 00:01:24,900 So finally, once we get that data, well, then use it to update our users piece of state, which was 19 00:01:24,900 --> 00:01:26,070 already defined up here. 20 00:01:27,210 --> 00:01:34,550 We can do a set, users assign data like so, and that should be it, and sure enough, there's my list 21 00:01:34,550 --> 00:01:38,090 of users, so I'm going to check my solution and see how I'm doing. 22 00:01:40,990 --> 00:01:42,790 As usual, little pause here. 23 00:01:43,060 --> 00:01:44,020 All right, there we go. 24 00:01:44,170 --> 00:01:44,890 Looks perfect. 25 00:01:45,650 --> 00:01:47,560 Let's take a pause right here and continue on.