1
00:00:01,170 --> 00:00:01,800
Welcome back.

2
00:00:02,220 --> 00:00:08,400
Now what we need to do is that we need to get a movie by adding, here we have it, all movies, so

3
00:00:08,400 --> 00:00:14,850
here we will get all movies regardless of the title or the year.

4
00:00:15,240 --> 00:00:17,490
We are just going to get all of the movies that we have.

5
00:00:18,090 --> 00:00:20,400
However, this is not always useful.

6
00:00:21,030 --> 00:00:28,230
In many cases, we need to return a specific piece of data, whether it be movies or whether it be something

7
00:00:28,230 --> 00:00:28,560
else.

8
00:00:28,980 --> 00:00:31,110
But in our case, we are returning.

9
00:00:31,590 --> 00:00:34,560
Therefore, we need to return a movie by it.

10
00:00:35,550 --> 00:00:45,380
So there are, there are there must be a you are ill in your API that would return a movie by item and

11
00:00:45,450 --> 00:00:51,000
that can be can be done creating a new by creating a new audio.

12
00:00:51,300 --> 00:00:53,580
So we need to create a new, new audio.

13
00:00:54,300 --> 00:00:56,400
So I'm going to say here at app.

14
00:00:57,550 --> 00:01:06,040
Got to get out of then you're going to see a movie and he wants you to notice the difference here.

15
00:01:06,370 --> 00:01:08,430
Here I am seeing movies here.

16
00:01:08,440 --> 00:01:12,280
I'm seeing movie singular here, plural here, singular.

17
00:01:14,050 --> 00:01:20,320
The reason why I'm doing this is because, again, we want to be consistent whenever you are building

18
00:01:20,320 --> 00:01:21,940
and working on an API.

19
00:01:22,330 --> 00:01:31,150
It's super important and crucial to be consistent and be meaningful with your API endpoints because

20
00:01:31,150 --> 00:01:33,610
clients who are going to be using your applications.

21
00:01:34,760 --> 00:01:42,860
If they don't if they don't get a meaningful end points, they are going to be confused.

22
00:01:42,950 --> 00:01:48,050
Just put yourself in their shoes, in their shoes and then you will be confused if you don't know if

23
00:01:48,050 --> 00:01:52,340
you if if your API endpoints don't have meaningful names.

24
00:01:52,910 --> 00:01:56,390
So here we need to see a movie and then I'm using again.

25
00:01:56,720 --> 00:01:59,840
I'm using the get request because we are going to get.

26
00:02:00,020 --> 00:02:01,760
We are going to get only a single movie.

27
00:02:02,300 --> 00:02:03,350
So I'm going to say you get.

28
00:02:05,110 --> 00:02:06,910
Single movie.

29
00:02:10,060 --> 00:02:13,500
And then we need to get the function that would return that.

30
00:02:13,810 --> 00:02:16,870
So I'm going to say your debt and then get.

31
00:02:19,200 --> 00:02:19,700
Get.

32
00:02:24,180 --> 00:02:26,040
Get moving.

33
00:02:32,090 --> 00:02:42,610
It's movie, night movies, movie, singular, and since since now we are we are, since now we are

34
00:02:42,910 --> 00:02:44,680
getting a specific movie.

35
00:02:45,070 --> 00:02:50,890
We need to pass the idea of that movie because think about it, how can we get a specific movie from

36
00:02:50,890 --> 00:02:57,700
a big array or from the database in order to get a specific piece of data we need to to to know it's

37
00:02:58,450 --> 00:03:06,170
the only thing that is unique about about any piece of data in in an IRA or a database.

38
00:03:06,200 --> 00:03:09,100
It's therefore in the endpoint.

39
00:03:09,100 --> 00:03:14,260
We need to say for that, but then clearly brackets and then we need to pass.

40
00:03:14,260 --> 00:03:17,170
The movie underscore idea.

41
00:03:17,650 --> 00:03:19,840
We need to know the idea of that movie.

42
00:03:20,200 --> 00:03:29,480
Otherwise, we wouldn't be able to get that, get that movie and in the function in order to in order

43
00:03:29,500 --> 00:03:38,410
for the function, to talk to the arrays or to talk to the array, so to speak, it must be given the

44
00:03:38,410 --> 00:03:38,680
ID.

45
00:03:38,770 --> 00:03:43,810
So we need to see a movie underscore it, which is integer.

46
00:03:44,710 --> 00:03:52,450
And then inside that function, we can access the movies array, we can say movies and then we can get

47
00:03:52,690 --> 00:03:53,890
that specific movie.

48
00:03:54,070 --> 00:03:57,010
We can get that movie from that era.

49
00:03:57,580 --> 00:04:00,550
So in order to get that movie from that era, we need to say you.

50
00:04:01,630 --> 00:04:02,410
Movie I've.

51
00:04:04,220 --> 00:04:05,240
Minus one.

52
00:04:05,990 --> 00:04:10,580
Why am I in this one, because any array starts with zero?

53
00:04:11,670 --> 00:04:14,960
NRA would start with the first.

54
00:04:15,200 --> 00:04:17,780
The first element has an index of zero.

55
00:04:18,350 --> 00:04:21,380
The second element, which is this has an index of one.

56
00:04:21,830 --> 00:04:28,100
The third element has an index of two, etc. So in order to return the first movie, we need to get

57
00:04:28,100 --> 00:04:30,440
its idea and then we need to decrease it by one.

58
00:04:31,610 --> 00:04:32,830
This is a solution.

59
00:04:32,840 --> 00:04:41,030
Another solution that I like to do is that I like to pass an empty object, so the empty object would

60
00:04:41,810 --> 00:04:44,810
would have nothing would have just empty.

61
00:04:45,790 --> 00:04:50,950
Empty title, empty title, an empty beer.

62
00:04:53,780 --> 00:04:54,830
Empty here.

63
00:04:57,010 --> 00:05:05,740
And then this this object that is that has a an index of zero would never be used, I would never use

64
00:05:05,740 --> 00:05:05,890
it.

65
00:05:06,370 --> 00:05:13,570
So the user, whenever the user passes a on it, I'm just going to say, well, the idea without minus

66
00:05:13,570 --> 00:05:13,780
one.

67
00:05:14,290 --> 00:05:19,390
So the first movie in this in this case, the first movie would have an idea of one.

68
00:05:20,110 --> 00:05:29,590
This way, you would end the and eliminate the and view the confusion about this so you wouldn't be

69
00:05:29,590 --> 00:05:32,980
confused whenever you are trying to get a specific movie.

70
00:05:33,340 --> 00:05:36,100
So the first movie would be would have an idea of one.

71
00:05:36,100 --> 00:05:40,060
The second movie would have an idea of two, that everything would be perfect.

72
00:05:40,330 --> 00:05:41,500
And I like this technique.

73
00:05:42,100 --> 00:05:46,720
This technique is awesome because you don't have to decrease by one and do anything.

74
00:05:46,720 --> 00:05:53,230
You just need to say the movies and the movie by it and then return to her.

75
00:05:53,920 --> 00:05:54,490
And that's it.

76
00:05:54,520 --> 00:05:58,240
Now let me go to the browser, and let's refresh.

77
00:05:59,140 --> 00:06:02,530
Now, if you refresh, you will find that we have a new year.

78
00:06:03,520 --> 00:06:07,690
You are L, which is get if you click on it here.

79
00:06:08,830 --> 00:06:15,100
Let's hear try this out, I'm going to click try out, and here it says movie idea, we need to provide

80
00:06:15,130 --> 00:06:15,850
the movie I.D..

81
00:06:16,270 --> 00:06:17,200
Let me say one.

82
00:06:17,200 --> 00:06:24,190
If I say you want an excuse, as you can see, I'm going to get Batman to 2001, so I'm going to get

83
00:06:24,190 --> 00:06:31,390
the first movie, which is this if I say to, let's say to, let's say, in year two.

84
00:06:32,560 --> 00:06:34,090
Let me set you to an excuse.

85
00:06:35,050 --> 00:06:38,320
I'm going to get the second movie if I say three.

86
00:06:40,820 --> 00:06:43,470
And execute, I'm going to get to you.

87
00:06:43,490 --> 00:06:49,550
Nothing, it says internal server error, because we don't have a movie that has that idea.

88
00:06:50,060 --> 00:06:51,890
There is no movie that has this idea.

89
00:06:52,730 --> 00:06:55,400
So now we know how to get a movie by it.

90
00:06:56,120 --> 00:07:01,730
And again, it's important to implement this technique whenever you are dealing with areas in order

91
00:07:01,730 --> 00:07:03,720
to eliminate the confusion.

92
00:07:04,370 --> 00:07:11,120
You need to you need to pass an empty object at the beginning so that the first element would have one

93
00:07:12,620 --> 00:07:13,070
off one.
