All right.
Let's put together that fetched tracks action function and make sure that we get a list of tracks tied
to the current user so inside of track context I'm going to expand that function inside of here we definitely
want to make a request to our API so going to mark the inner function as being async like so then inside
of here we'll make a request and get a response with a weight tracker API dot get slash tracks to remember
anytime we make a request the code that we just added into our axis file right here is going to automatically
append in that token so our back and API is going to take that token use it to identify our user and
then automatically respond respond with a list of different checks that have been created by them so
inside the response variable right there is the data property and that should contain an array of different
objects where each object is a track that a user has created.
Then once we get that response we can dispatch an action with a type of like maybe fetch tracks and
a payload of response dot data then inside of a producer we can watch for batch tracks and whenever
we see that we can return action dot payload.
Notice how we're not trying to add in all these tracks right here to our existing state.
In general we always treat our API as kind of like a total source of truth.
So whenever we make this request right here and get back a list of tracks we're just going to say OK
throw away whatever state we have let's just trust the data that we got back from our API.
So we're going to return just what we got from our API okay.
So that should pretty much be it right there.
It's now we've got this put together we can successfully get some list of tracks from our API that the
user has created.
Let's take one more quick pause when we come back the next video.
Looks like I got an error here.
I think I just made a little typo at some point yeah.
There we go.
Let's take a quick pause.
We come back the next video we'll make sure that we call it fetch tracks from our tracklist screen and
then render them out to the user.