Let's add in some logic inside of our tribe block to use Axios to make a request over to the NPM API
to do so, I'm going to get some data back from Axios.
I'll do it and await Axios Moorgate.
I'll put in our URL right there.
So for our URL, we'll write in HTTPS Colon Slash Registry, NPM, Jörg.
And then a slash.
A dash.
Another slash.
The one zorch.
We then have to add on a query string to indicate what library we are actually searching for.
So as a second argument, I'm going to put in an object.
I'm going to add in a Pyramus property to it, and then inside there I will provide text and the value
for text is going to come from term.
So, again, perhaps right here is what's going to get our query string into that URL.
Now, we can take this data right here and do some processing on it and pull off all the names of these
different libraries as a very quick reminder, the information that we get back from this NPM API.
Let's just make a request over once again, if I can find.
Browser window that still has that request inside of it.
Here it is, you pull it on the screen.
Here we go.
So here's the response we get back from the NPR API, so we want to go into that data property that
we just structured off, that object that we get back from Axios.
I want to get the objects property that's going to be an array of objects.
And each of those objects has a package property to offer that that package property we want to get
off name and that will give us the name of the library itself.
So.
Back over inside of our code, we really want to take a look at data.
Objects, I want to map over that.
The map statement is going to give us this object right here, so out of that object, I want to get
the package property name.
So I'm going to get an argument that will call a result.
I'm then going to return results, that package name I'm getting an air from result right here.
I'm going to end this one as any for just a moment.
Then we'll take this entire map to a right here that should have all of our package names.
I'm going to assign it to a variable that I'll call simply names.
And then finally, we will dispatch an action.
So in this case, we want to dispatch an action with type action type dot search repository success
and our payload will be names.
And that should be it.
OK, so let's save this this crater looks pretty reasonable, I think the last big thing we have to
do inside of here is just make sure that we export the action crater itself.
So put in an expert search repositories, you will notice that we are currently not making use of this
action import.
We will in just a moment to take a quick pause right here at the action crater is all put together.
And I want to take a look at some ways we can improve this action crater in just a moment.