1
00:00:01,950 --> 00:00:07,110
Let's add in some logic inside of our tribe block to use Axios to make a request over to the NPM API

2
00:00:07,620 --> 00:00:11,940
to do so, I'm going to get some data back from Axios.

3
00:00:12,750 --> 00:00:15,270
I'll do it and await Axios Moorgate.

4
00:00:15,690 --> 00:00:17,450
I'll put in our URL right there.

5
00:00:18,240 --> 00:00:26,340
So for our URL, we'll write in HTTPS Colon Slash Registry, NPM, Jörg.

6
00:00:27,090 --> 00:00:28,260
And then a slash.

7
00:00:29,040 --> 00:00:29,880
A dash.

8
00:00:30,600 --> 00:00:31,560
Another slash.

9
00:00:32,580 --> 00:00:34,020
The one zorch.

10
00:00:35,000 --> 00:00:39,440
We then have to add on a query string to indicate what library we are actually searching for.

11
00:00:39,830 --> 00:00:42,170
So as a second argument, I'm going to put in an object.

12
00:00:43,230 --> 00:00:49,230
I'm going to add in a Pyramus property to it, and then inside there I will provide text and the value

13
00:00:49,230 --> 00:00:50,940
for text is going to come from term.

14
00:00:52,460 --> 00:00:55,610
So, again, perhaps right here is what's going to get our query string into that URL.

15
00:00:56,710 --> 00:01:01,360
Now, we can take this data right here and do some processing on it and pull off all the names of these

16
00:01:01,360 --> 00:01:06,380
different libraries as a very quick reminder, the information that we get back from this NPM API.

17
00:01:06,400 --> 00:01:11,320
Let's just make a request over once again, if I can find.

18
00:01:12,780 --> 00:01:15,170
Browser window that still has that request inside of it.

19
00:01:16,930 --> 00:01:18,700
Here it is, you pull it on the screen.

20
00:01:20,390 --> 00:01:20,940
Here we go.

21
00:01:21,680 --> 00:01:26,300
So here's the response we get back from the NPR API, so we want to go into that data property that

22
00:01:26,300 --> 00:01:29,930
we just structured off, that object that we get back from Axios.

23
00:01:30,440 --> 00:01:33,560
I want to get the objects property that's going to be an array of objects.

24
00:01:34,100 --> 00:01:39,500
And each of those objects has a package property to offer that that package property we want to get

25
00:01:39,500 --> 00:01:41,930
off name and that will give us the name of the library itself.

26
00:01:42,830 --> 00:01:43,280
So.

27
00:01:44,190 --> 00:01:47,700
Back over inside of our code, we really want to take a look at data.

28
00:01:49,080 --> 00:01:52,170
Objects, I want to map over that.

29
00:01:56,830 --> 00:02:03,100
The map statement is going to give us this object right here, so out of that object, I want to get

30
00:02:03,100 --> 00:02:04,990
the package property name.

31
00:02:05,940 --> 00:02:08,759
So I'm going to get an argument that will call a result.

32
00:02:10,009 --> 00:02:16,910
I'm then going to return results, that package name I'm getting an air from result right here.

33
00:02:16,940 --> 00:02:20,270
I'm going to end this one as any for just a moment.

34
00:02:21,520 --> 00:02:25,780
Then we'll take this entire map to a right here that should have all of our package names.

35
00:02:26,800 --> 00:02:30,700
I'm going to assign it to a variable that I'll call simply names.

36
00:02:32,190 --> 00:02:34,860
And then finally, we will dispatch an action.

37
00:02:36,160 --> 00:02:42,610
So in this case, we want to dispatch an action with type action type dot search repository success

38
00:02:42,910 --> 00:02:45,010
and our payload will be names.

39
00:02:46,750 --> 00:02:47,560
And that should be it.

40
00:02:50,180 --> 00:02:55,010
OK, so let's save this this crater looks pretty reasonable, I think the last big thing we have to

41
00:02:55,010 --> 00:02:58,100
do inside of here is just make sure that we export the action crater itself.

42
00:02:58,490 --> 00:03:04,130
So put in an expert search repositories, you will notice that we are currently not making use of this

43
00:03:04,130 --> 00:03:05,000
action import.

44
00:03:05,210 --> 00:03:10,220
We will in just a moment to take a quick pause right here at the action crater is all put together.

45
00:03:10,460 --> 00:03:14,000
And I want to take a look at some ways we can improve this action crater in just a moment.

