1
00:00:00,150 --> 00:00:07,170
All right, and once we're familiar with Posman now, let's work on the other two methods, so now we're

2
00:00:07,170 --> 00:00:11,660
going to be working on put method as well as the delete.

3
00:00:12,150 --> 00:00:16,379
So I'm going to scroll down and below the post logging around.

4
00:00:16,710 --> 00:00:19,260
I'm going to go with app and input.

5
00:00:19,620 --> 00:00:24,140
Now, again, this method is for editing the data.

6
00:00:24,360 --> 00:00:27,050
So put method is for update.

7
00:00:27,510 --> 00:00:34,260
And again, the convention is following where if we have a list, for example, in this case that would

8
00:00:34,260 --> 00:00:35,910
be AP and honors.

9
00:00:36,240 --> 00:00:45,870
If we want to edit or delete, we go with our route parameter where effectively we set up a route for

10
00:00:45,870 --> 00:00:52,650
API orders and then we go with Colen ID and this is going to get me that one specific item.

11
00:00:52,920 --> 00:00:57,600
Now, please keep in mind one thing where this is a convention.

12
00:00:57,990 --> 00:01:01,410
So technically there are multiple other ways how you can set it up.

13
00:01:01,530 --> 00:01:06,960
But there is a reason why that convention exists and that's why throughout the course we all stick with

14
00:01:06,960 --> 00:01:07,710
this convention.

15
00:01:08,070 --> 00:01:13,710
I will cover the official name of this convention a little bit later, as well as a bit more details

16
00:01:13,710 --> 00:01:14,100
about it.

17
00:01:14,400 --> 00:01:19,740
For now, I just quickly want to cover both of the methods, so I'm going to navigate back.

18
00:01:19,740 --> 00:01:23,430
I have my put method that is for modifying the data.

19
00:01:23,670 --> 00:01:27,960
And in our case, what is the URL for the whole list?

20
00:01:28,230 --> 00:01:29,850
Because that is API people.

21
00:01:30,220 --> 00:01:32,460
So this was just for testing.

22
00:01:32,490 --> 00:01:32,900
Correct.

23
00:01:33,210 --> 00:01:38,490
And then we go with API forward slash and then we go with people.

24
00:01:39,180 --> 00:01:41,790
And then of course, I also want to add that.

25
00:01:42,420 --> 00:01:45,900
So this is going to get me that one specific item.

26
00:01:46,290 --> 00:01:52,980
And again, the reason why we're doing that, because when we'll send our post or delete requests,

27
00:01:53,310 --> 00:01:55,760
we'll send to a specific path.

28
00:01:56,130 --> 00:01:58,710
So this is going to be that one item.

29
00:01:59,070 --> 00:02:06,600
And if that exists, then in the body, there's going to be data to update or in the case of the lead,

30
00:02:06,600 --> 00:02:07,830
there's going to be nothing in the body.

31
00:02:08,009 --> 00:02:12,160
We'll just remove that item and you'll see how it works in a second.

32
00:02:12,180 --> 00:02:13,370
So please be patient.

33
00:02:13,620 --> 00:02:17,750
So we're going to go with people and then remember, again, we have aroud programs.

34
00:02:17,970 --> 00:02:20,880
And in this case, I'm not going to call this personally.

35
00:02:20,880 --> 00:02:22,040
I'm just going to say it.

36
00:02:22,320 --> 00:02:26,100
Just remember that we can call it technically whatever we want.

37
00:02:26,400 --> 00:02:28,920
And now in this case, there's two things that I'm looking for.

38
00:02:29,220 --> 00:02:32,790
First, I want to get the value here in the primes.

39
00:02:32,790 --> 00:02:36,180
And remember, we access that using the rec programs.

40
00:02:36,390 --> 00:02:43,350
And the second thing, when it comes to update, when it comes to the request, I'm also going to send

41
00:02:43,350 --> 00:02:44,660
something in about it.

42
00:02:44,700 --> 00:02:44,990
Why?

43
00:02:45,240 --> 00:02:51,330
Well, because if I'm updating, for example, if I'm changing the name from Peter to Susan or whatever,

44
00:02:51,490 --> 00:02:51,930
of course.

45
00:02:51,930 --> 00:02:53,690
And you also need to supply this value.

46
00:02:54,000 --> 00:02:58,140
So you need to understand that there's two sides of this request.

47
00:02:58,410 --> 00:03:02,880
Not only we looking for that specific item, that's why we use the primes.

48
00:03:03,150 --> 00:03:09,200
That's why I specifically say, hey, I would like to get the item number one or an item number two.

49
00:03:09,540 --> 00:03:14,420
I also need to supply this value because otherwise, what's the point of updating something?

50
00:03:14,700 --> 00:03:17,040
So let's access both of those things.

51
00:03:17,290 --> 00:03:21,770
Let's say that I'm going to get the ID from REC programs.

52
00:03:22,140 --> 00:03:24,360
So this is going to tell me which item.

53
00:03:24,600 --> 00:03:27,990
And then the second thing since, of course, I want to update that item.

54
00:03:28,110 --> 00:03:29,570
I need that value as well.

55
00:03:29,790 --> 00:03:30,190
Correct.

56
00:03:30,450 --> 00:03:32,880
So we're going to go here with const.

57
00:03:33,790 --> 00:03:39,970
And I'm going to be, again, looking for the name and we'll say Gadot body and that's it.

58
00:03:40,240 --> 00:03:41,170
That should do it.

59
00:03:41,410 --> 00:03:47,800
So these are the two values that we're going to get from our quest just to make things interesting and

60
00:03:47,800 --> 00:03:49,490
we'll console them right now.

61
00:03:49,810 --> 00:03:55,870
So I'm going to go back to the postman and remember, we need to change the URL.

62
00:03:56,140 --> 00:03:58,750
It's not going to be a postman in this case.

63
00:03:58,750 --> 00:03:59,890
It is going to be people.

64
00:04:00,100 --> 00:04:06,750
And now you can select any of the ideas, whether or not one all the way up to the five.

65
00:04:07,000 --> 00:04:09,250
So we go here with one.

66
00:04:09,850 --> 00:04:13,180
And then as far as the value, what is the value for the first one?

67
00:04:13,330 --> 00:04:13,970
It is, John.

68
00:04:14,320 --> 00:04:15,550
So kind of makes sense.

69
00:04:15,550 --> 00:04:17,720
If I'm updating that I go with Bill.

70
00:04:17,829 --> 00:04:18,230
Correct.

71
00:04:18,459 --> 00:04:19,930
So we have put the request.

72
00:04:19,930 --> 00:04:24,940
We have API and then people and then check it out the moment we send it.

73
00:04:25,160 --> 00:04:27,120
And of course, the request is hanging.

74
00:04:27,310 --> 00:04:28,300
Don't worry about that.

75
00:04:28,570 --> 00:04:34,480
But in the console we should get API people and then the ID.

76
00:04:34,930 --> 00:04:40,330
And of course the reason why I don't see anything because I was smart enough and I didn't cancel anything.

77
00:04:40,570 --> 00:04:42,700
So I'm going to go back with a name.

78
00:04:43,030 --> 00:04:43,660
And you know what?

79
00:04:43,670 --> 00:04:46,590
For timing, let me just send back a little world.

80
00:04:47,140 --> 00:04:48,520
OK, let's go here.

81
00:04:48,820 --> 00:04:52,170
Let's actually send in one more time, as you can see.

82
00:04:52,330 --> 00:04:53,470
Could not get the response.

83
00:04:53,470 --> 00:04:54,660
That was the error this time.

84
00:04:54,970 --> 00:04:57,280
In this case, I am getting Hello World.

85
00:04:57,670 --> 00:04:58,960
So that worked beautifully.

86
00:04:59,210 --> 00:05:02,350
And as you can see, the status code is two hundred as well.

87
00:05:02,620 --> 00:05:07,300
And that in a console I have one and I have the beta.

88
00:05:07,750 --> 00:05:11,930
So this is going to be the ID and of course this is going to be the value.

89
00:05:12,190 --> 00:05:18,730
Now if I'll change it, of course, if I say no to and if I send it again, I get back my response.

90
00:05:18,910 --> 00:05:23,940
And now the value for the idea is to hopefully this makes sense.

91
00:05:24,060 --> 00:05:27,250
So now, of course, at this point, we need to set up the logic again.

92
00:05:27,640 --> 00:05:35,650
We are going to set up the logic with our local data, with our people are eventually in next examples

93
00:05:35,860 --> 00:05:37,780
will work actually with database.

94
00:05:38,020 --> 00:05:39,850
But the main idea is exactly the same.

95
00:05:40,360 --> 00:05:47,110
Where from the postman, while we're testing, we're sending the ID in the URL.

96
00:05:47,350 --> 00:05:52,420
Basically, we add that you are a programmer and then in the body will send the value.

97
00:05:52,870 --> 00:05:56,170
So that part won't change just the functionality in here.

98
00:05:56,500 --> 00:06:03,400
And as far as this functionality, well, since we have a simple JavaScript array, first I will just

99
00:06:03,400 --> 00:06:05,890
want to get the person with that ID.

100
00:06:06,430 --> 00:06:15,100
If the person doesn't exist, then I'll send back the error response and if the ideas exist, then I'll

101
00:06:15,100 --> 00:06:16,010
just change the value.

102
00:06:16,270 --> 00:06:18,730
Now, I'm not going to be looking for the error message.

103
00:06:18,730 --> 00:06:22,420
If the value is not provided, we're going to cover that once.

104
00:06:22,420 --> 00:06:24,040
Actually, we work with database.

105
00:06:24,430 --> 00:06:28,420
I think it's just going to be at the moment, waste of our time.

106
00:06:28,750 --> 00:06:30,250
So let's do it, people.

107
00:06:30,790 --> 00:06:32,820
I'm going to remove both of these council logs.

108
00:06:32,830 --> 00:06:37,550
Hopefully you understand how we supply both values in the postman.

109
00:06:37,720 --> 00:06:44,830
And I'm going to start by creating a person and this is going to be equal to people that find again,

110
00:06:44,830 --> 00:06:48,250
I have the array, so I have access to all the array methods.

111
00:06:48,520 --> 00:06:56,140
And if the person the matches to my primary, then of course I'm going to get the person.

112
00:06:56,380 --> 00:06:59,420
Now, let me check in the data notice.

113
00:06:59,650 --> 00:07:03,940
I still have it as a number, so I'll have to change the type as well.

114
00:07:04,150 --> 00:07:12,310
So I'll say if person ID is equal to a number and I'll pass in the ID that I'm getting from my programs,

115
00:07:12,640 --> 00:07:16,390
whether that's one five or maybe it's going to be ID, that doesn't make sense.

116
00:07:16,780 --> 00:07:17,830
All right, good.

117
00:07:18,100 --> 00:07:25,690
And if the person doesn't exist, well, then I'll send back the response now again, in order to save

118
00:07:25,690 --> 00:07:32,140
us a little bit of time, I'll scroll up and I'll look for any of my error messages since I just want

119
00:07:32,140 --> 00:07:34,420
to copy and paste and change some values around.

120
00:07:34,690 --> 00:07:37,150
So in this case, I'm going to look for this name.

121
00:07:37,150 --> 00:07:41,230
If it doesn't exist, then of course we have the error.

122
00:07:41,560 --> 00:07:46,210
And in our case, of course, we just need to change it around if the person doesn't exist.

123
00:07:46,210 --> 00:07:51,580
So if we kind of find that in the array, then we're sending back four hundred and four.

124
00:07:52,120 --> 00:07:54,070
Remember, that was a status code.

125
00:07:54,370 --> 00:07:56,710
If we cannot find the resource.

126
00:07:56,950 --> 00:07:59,860
And as far as the response, we have success.

127
00:08:00,070 --> 00:08:01,720
And of course it's going to be false.

128
00:08:02,020 --> 00:08:03,770
And now let's go with message.

129
00:08:04,060 --> 00:08:06,760
And in the message we're going to use a template.

130
00:08:06,760 --> 00:08:12,970
String will say no person with ID and then I'm just going to pass in the edit.

131
00:08:13,540 --> 00:08:18,490
So that's the first response if of course, the person doesn't exist.

132
00:08:18,640 --> 00:08:26,170
So if in the primes we enter, for example, value six, we know that we have only one to five or ABC.

133
00:08:26,590 --> 00:08:32,110
Now, the second thing, if the person does exist now, of course, I just want to iterate over the

134
00:08:32,110 --> 00:08:32,409
array.

135
00:08:33,409 --> 00:08:41,659
And for that specific person, for the person whose I.D. matches my firearms value, I'll change the

136
00:08:41,659 --> 00:08:45,110
name since I'm expecting that one to be in about it.

137
00:08:45,150 --> 00:08:47,510
Again, we're not going to deal with this error for now.

138
00:08:47,750 --> 00:08:52,430
We'll do that once we work with database and we're going to go with new people.

139
00:08:53,400 --> 00:09:02,010
New people here and will say people maps are iterating over my right again, our reference each and

140
00:09:02,010 --> 00:09:12,030
every person as a person, and I'll say if person ID matches to that one I have in the primes, so no

141
00:09:12,030 --> 00:09:20,100
ID again, then I'm going to say person name, since that is the only other property I have is equal

142
00:09:20,280 --> 00:09:21,630
to my name.

143
00:09:21,750 --> 00:09:25,620
Now where I'm getting the name was I'm getting it from the body.

144
00:09:26,100 --> 00:09:32,580
So if the ID of the person matches to that one in the prompt then please change the name that I can

145
00:09:32,580 --> 00:09:34,130
find anybody.

146
00:09:34,410 --> 00:09:42,420
If not then simply return a person, return a person and of course all the way in the bottom, I'm going

147
00:09:42,420 --> 00:09:50,430
to go with that status and we're sending back two hundred since the request was successful.

148
00:09:50,640 --> 00:09:55,440
As far as the JSON, we go with success or sorry, not super.

149
00:09:55,830 --> 00:09:57,300
We're going to go with success.

150
00:09:57,930 --> 00:09:58,380
Tril.

151
00:09:59,260 --> 00:10:04,990
And then as far as data, well, now I'm sending back the new people, so let's go back.

152
00:10:05,470 --> 00:10:07,170
At this point, I have to.

153
00:10:07,730 --> 00:10:13,150
So let me change it back to one, because I know for sure that, first of all, you want John.

154
00:10:13,570 --> 00:10:19,480
Again, the path is API people and the idea of one.

155
00:10:19,720 --> 00:10:23,870
And I just want to change it from John to Peter.

156
00:10:24,160 --> 00:10:25,780
So let me double check in data.

157
00:10:25,990 --> 00:10:27,190
This should be John.

158
00:10:27,850 --> 00:10:33,030
It's a good thing I didn't go with the idea of Q since that one is already beta.

159
00:10:33,220 --> 00:10:36,120
So now let me send it and check it out.

160
00:10:36,580 --> 00:10:46,300
Now I have success through and data of course is Meira and instead of name being John for the person

161
00:10:46,300 --> 00:10:46,840
number one.

162
00:10:47,060 --> 00:10:49,000
Now the name is Spear.

163
00:10:49,300 --> 00:10:55,510
And of course if I'll do the same thing, for example, for person number three, then we send it back.

164
00:10:55,510 --> 00:11:01,130
Of course, now I have three because I just keep changing those values and then we're not persisting,

165
00:11:01,130 --> 00:11:01,630
not there.

166
00:11:01,990 --> 00:11:09,010
But while we're making requests, you can clearly see how we are modifying this data and we do that

167
00:11:09,010 --> 00:11:11,830
using HTP put method.

168
00:11:12,650 --> 00:11:20,390
And then, of course, the path is API people and then whatever, and again, the whole reason why is

169
00:11:20,390 --> 00:11:24,410
that happening, because on our server we are handling that.

