1 00:00:01,280 --> 00:00:01,590 All right. 2 00:00:01,620 --> 00:00:05,670 Let's put together that fetched tracks action function and make sure that we get a list of tracks tied 3 00:00:05,670 --> 00:00:12,060 to the current user so inside of track context I'm going to expand that function inside of here we definitely 4 00:00:12,060 --> 00:00:19,280 want to make a request to our API so going to mark the inner function as being async like so then inside 5 00:00:19,280 --> 00:00:27,980 of here we'll make a request and get a response with a weight tracker API dot get slash tracks to remember 6 00:00:28,040 --> 00:00:34,010 anytime we make a request the code that we just added into our axis file right here is going to automatically 7 00:00:34,010 --> 00:00:40,370 append in that token so our back and API is going to take that token use it to identify our user and 8 00:00:40,370 --> 00:00:45,590 then automatically respond respond with a list of different checks that have been created by them so 9 00:00:45,690 --> 00:00:51,000 inside the response variable right there is the data property and that should contain an array of different 10 00:00:51,120 --> 00:00:56,250 objects where each object is a track that a user has created. 11 00:00:56,330 --> 00:01:04,810 Then once we get that response we can dispatch an action with a type of like maybe fetch tracks and 12 00:01:04,810 --> 00:01:14,380 a payload of response dot data then inside of a producer we can watch for batch tracks and whenever 13 00:01:14,380 --> 00:01:18,880 we see that we can return action dot payload. 14 00:01:18,880 --> 00:01:23,500 Notice how we're not trying to add in all these tracks right here to our existing state. 15 00:01:23,650 --> 00:01:27,550 In general we always treat our API as kind of like a total source of truth. 16 00:01:28,060 --> 00:01:32,470 So whenever we make this request right here and get back a list of tracks we're just going to say OK 17 00:01:32,500 --> 00:01:37,200 throw away whatever state we have let's just trust the data that we got back from our API. 18 00:01:37,750 --> 00:01:41,570 So we're going to return just what we got from our API okay. 19 00:01:41,600 --> 00:01:43,240 So that should pretty much be it right there. 20 00:01:43,240 --> 00:01:47,740 It's now we've got this put together we can successfully get some list of tracks from our API that the 21 00:01:47,740 --> 00:01:49,430 user has created. 22 00:01:49,450 --> 00:01:52,550 Let's take one more quick pause when we come back the next video. 23 00:01:52,550 --> 00:01:53,490 Looks like I got an error here. 24 00:01:53,500 --> 00:01:58,200 I think I just made a little typo at some point yeah. 25 00:01:58,200 --> 00:01:59,160 There we go. 26 00:01:59,190 --> 00:02:00,030 Let's take a quick pause. 27 00:02:00,020 --> 00:02:04,200 We come back the next video we'll make sure that we call it fetch tracks from our tracklist screen and 28 00:02:04,200 --> 00:02:05,610 then render them out to the user.