1
00:00:00,150 --> 00:00:07,440
All right, and the last method I would like to cover is a delete method, so below the put method,

2
00:00:07,590 --> 00:00:11,220
below the modifier option, I'm going to go with AB.

3
00:00:12,030 --> 00:00:14,520
The method is delete again.

4
00:00:14,520 --> 00:00:23,580
The convention, if you have a list, is going with a list, YORO, and then add that specific idy because

5
00:00:23,580 --> 00:00:27,180
the setup is going to be extremely similar to a put one.

6
00:00:27,510 --> 00:00:32,220
Now the only difference is, is going to be that of course in this case when we're deleting, we're

7
00:00:32,220 --> 00:00:35,190
not expecting anything in the body if.

8
00:00:36,050 --> 00:00:43,880
The user hits the URL, for example, API people, and then one, we just removed that sucker from our

9
00:00:43,880 --> 00:00:44,240
list.

10
00:00:44,400 --> 00:00:44,900
That's it.

11
00:00:45,470 --> 00:00:48,980
So let's go down where we have app lead.

12
00:00:49,250 --> 00:00:54,830
And again, the path is following where we go with API and then people.

13
00:00:55,220 --> 00:01:01,310
And again, let me stress one more time something where these routes are different.

14
00:01:02,400 --> 00:01:11,010
When we talk about Abdulbaset and API people, when we talk about app that post and API people, or

15
00:01:11,010 --> 00:01:18,420
even if we talk about app that put an app that delete just because the path is the same, since the

16
00:01:18,420 --> 00:01:21,450
method is different, these are different requests.

17
00:01:21,660 --> 00:01:22,790
That is crucial.

18
00:01:23,220 --> 00:01:29,220
Please don't think that just because you have a different method, you have to set up a whole new path.

19
00:01:29,430 --> 00:01:32,570
No, you can have the same value for the path.

20
00:01:32,580 --> 00:01:36,580
If the method is different, that is totally different request.

21
00:01:36,930 --> 00:01:39,360
So let's go here again with our callback function.

22
00:01:39,360 --> 00:01:41,370
We should already be comfortable with this one.

23
00:01:41,580 --> 00:01:47,670
We have Barack and Raz, and in this case, I'm not going to the structure of the idea from the problems.

24
00:01:47,860 --> 00:01:53,950
I just want to showcase that we also have this option of accessing the programs directly.

25
00:01:54,330 --> 00:01:59,490
So first, again, I want to look for the person, then we'll send back of this response.

26
00:01:59,500 --> 00:02:04,470
And yes, oftentimes put and delete are going to be extremely similar.

27
00:02:04,860 --> 00:02:10,710
And that if the person does exist, then, of course, I'll just filter out the array and remove that

28
00:02:10,710 --> 00:02:18,090
person from the array, since, again, the whole point of this request is to remove that person from

29
00:02:18,090 --> 00:02:18,570
the array.

30
00:02:18,990 --> 00:02:26,550
So in this case, I can actually copy and paste and I know some of you might find that annoying.

31
00:02:26,790 --> 00:02:32,070
But at the same time, we do need to speed this up and start working with a database.

32
00:02:32,400 --> 00:02:34,080
So hopefully you can forgive me.

33
00:02:34,260 --> 00:02:40,740
I'm just going to grab everything, starting with the person all the way until the end of our error

34
00:02:40,800 --> 00:02:44,700
response before or for the let's scroll down copy and paste.

35
00:02:44,940 --> 00:02:46,800
And this is what we're trying to do.

36
00:02:47,040 --> 00:02:53,160
So I'm trying to find a person whose ID matches that in the primes.

37
00:02:53,400 --> 00:02:57,760
And of course, in this case, I haven't structured the ID right.

38
00:02:57,990 --> 00:03:05,220
So I just need changes around where I go with Iraq and then programs and the ID again, the setup is

39
00:03:05,220 --> 00:03:06,040
exactly the same.

40
00:03:06,060 --> 00:03:13,500
The difference is that I'm directly accessing the program's object and if the person doesn't exist,

41
00:03:13,830 --> 00:03:16,290
then we send back the for four.

42
00:03:16,590 --> 00:03:18,450
So let's try this response.

43
00:03:19,320 --> 00:03:27,080
I'm going to go back to my postman again, the oppressed people, but we need to change the method.

44
00:03:27,180 --> 00:03:27,360
Right.

45
00:03:27,570 --> 00:03:33,540
So now I would want to delete and since I want to test out the error and as a sign up, you can send

46
00:03:33,540 --> 00:03:34,900
the body, doesn't really matter.

47
00:03:35,250 --> 00:03:39,560
We're not handling that on the server anyway, so it's really irrelevant.

48
00:03:39,780 --> 00:03:43,470
But since I want to test out the error, I'm going to go with ABC.

49
00:03:43,710 --> 00:03:48,600
So again, the path is localhost API people and then ABC.

50
00:03:48,780 --> 00:03:51,860
And if everything is correct, I should see the error.

51
00:03:52,080 --> 00:03:53,160
And of course there is.

52
00:03:53,430 --> 00:03:56,660
But something tells me that this is a different error.

53
00:03:56,970 --> 00:03:58,780
So let's go back and check it out.

54
00:03:59,070 --> 00:04:05,460
And of course, the issue is following notice here in the U.S. on how I'm accessing the area now.

55
00:04:05,460 --> 00:04:06,700
Of course, I have in the structure.

56
00:04:06,700 --> 00:04:11,130
And right in this case, I went with Rick programs and then Deery.

57
00:04:11,370 --> 00:04:17,339
So I'm going to go with Iraq programs and let's save it and let's try one more time.

58
00:04:17,640 --> 00:04:24,810
Again, I'm looking for a person whose ID doesn't exist, so I'm going to get the error and there is

59
00:04:25,020 --> 00:04:27,690
I have success, false.

60
00:04:28,050 --> 00:04:35,100
And as far as the message, no person with ID of A, B, C, so I was looking for the person.

61
00:04:36,070 --> 00:04:43,410
With I.D., that's not in my area, so that's why, of course, I got back the response.

62
00:04:43,690 --> 00:04:50,920
So now I'm going to go back to our delete request and here I just want to filter out the error and the

63
00:04:50,920 --> 00:04:53,200
way we're going to do that, I'm going to go with CONSED.

64
00:04:53,200 --> 00:04:58,470
New people is equal to people that filter.

65
00:04:58,870 --> 00:05:01,000
That's my Meyera and I'm just filtering.

66
00:05:01,000 --> 00:05:03,730
It will pass in my callback function.

67
00:05:05,140 --> 00:05:14,560
I'll reference each object where the person parameter and I'll just say if person I.D. does not match

68
00:05:14,920 --> 00:05:19,600
the ID found in Iraq, dot primes then return that person.

69
00:05:20,260 --> 00:05:23,020
If it does match, then it's not going to be included.

70
00:05:23,050 --> 00:05:28,990
That's why we go with my point and remember that we still get our idea as a string.

71
00:05:28,990 --> 00:05:33,970
So we must do the number one first and then only we go with primes.

72
00:05:34,240 --> 00:05:36,620
And so that's our new.

73
00:05:36,700 --> 00:05:42,840
All right, without that specific person whose ID matched the one in primes.

74
00:05:43,120 --> 00:05:51,190
So now, of course, let's just go with our return return, whereas that status here and this is going

75
00:05:51,190 --> 00:05:56,590
to be two hundred, of course, and I'm going to go to Jason and we'll set up our object.

76
00:05:56,770 --> 00:06:02,060
Success is true and I'll send back the new people.

77
00:06:02,090 --> 00:06:02,330
Right.

78
00:06:02,620 --> 00:06:07,270
So we're going to go with data and new people, let's say it.

79
00:06:08,140 --> 00:06:16,010
And let me start out in the postman, where, of course, now I'm going to go with ID that is in the

80
00:06:16,010 --> 00:06:17,770
area and I was going to be number one.

81
00:06:18,010 --> 00:06:25,660
So if I send notice how it is irrelevant if I send the body again because I'm not handling that on the

82
00:06:25,660 --> 00:06:26,620
server anyway.

83
00:06:26,920 --> 00:06:34,630
But if I take a look at my data, well, person with I.D. number one, John is missing.

84
00:06:34,630 --> 00:06:34,950
Why?

85
00:06:35,230 --> 00:06:39,550
Well, because his ID matched to the one that I passed in the prompts.

86
00:06:39,880 --> 00:06:42,840
So now, of course, he was removed from the area.

87
00:06:43,060 --> 00:06:48,880
So if I go with five, same deal now the John is back here because again, we're not persisting there,

88
00:06:49,270 --> 00:06:55,900
but the person with ID of five has been removed from the array.

89
00:06:56,410 --> 00:07:03,760
Hopefully this gives you a good understanding how we use other methods as well, not just get and why

90
00:07:03,940 --> 00:07:08,020
we go with Postman instead of setting up the front then.

91
00:07:08,380 --> 00:07:15,550
But before we cover routine express, let me just stress something that yes, while we're developing

92
00:07:15,550 --> 00:07:21,730
our server course, we'll use Postman because you can clearly see how much faster errors are set up

93
00:07:21,730 --> 00:07:23,890
throughout and I quickly test it.

94
00:07:24,340 --> 00:07:29,380
Otherwise, if I were to have to build a front end for every route that I'm creating, I mean, the

95
00:07:29,380 --> 00:07:32,290
process would be just very, very long.

96
00:07:32,590 --> 00:07:41,770
But the end of the day, when you set up the API, the expectation is that there is going to be someone

97
00:07:41,770 --> 00:07:45,250
who is using that data now that could be on your own server.

98
00:07:45,260 --> 00:07:51,310
So, for example, if you're building a full stack application with MERN, that's one of the options

99
00:07:51,520 --> 00:07:53,610
that could be decoupled application.

100
00:07:53,620 --> 00:08:02,110
Remember how I showed you a example where I have the API on my server, but then there is a react application

101
00:08:02,110 --> 00:08:06,040
that uses it doesn't mean that you have to build that front end application yourself.

102
00:08:06,520 --> 00:08:11,170
Just be mindful that the whole idea of setting up the API.

103
00:08:12,090 --> 00:08:15,310
Is that someone is going to be using that data?

104
00:08:15,870 --> 00:08:16,400
That's it.

105
00:08:16,410 --> 00:08:17,850
That's all I want to say.

106
00:08:18,090 --> 00:08:22,440
And of course, we can talk about router in Xpress.

