﻿1
00:00:01,010 --> 00:00:03,540
‫Finally, let's now handle the lead requests,

2
00:00:03,540 --> 00:00:04,403
‫as well.

3
00:00:05,550 --> 00:00:07,370
‫And just like in the previous lecture,

4
00:00:07,370 --> 00:00:09,280
‫I will not actually implement the deleting

5
00:00:09,280 --> 00:00:11,890
‫of a resource in our route handle.

6
00:00:11,890 --> 00:00:12,723
‫Okay?

7
00:00:12,723 --> 00:00:14,990
‫So, that is not necessary because, again,

8
00:00:14,990 --> 00:00:16,720
‫we are only dealing with files,

9
00:00:16,720 --> 00:00:20,150
‫which is not a real world scenario, okay?

10
00:00:20,150 --> 00:00:22,990
‫So I simply went ahead and copied the handler

11
00:00:22,990 --> 00:00:25,360
‫that we created in the last lecture.

12
00:00:25,360 --> 00:00:27,570
‫And so let's just do some quick changes here

13
00:00:27,570 --> 00:00:30,730
‫to handle the delete request, as well.

14
00:00:30,730 --> 00:00:33,260
‫So, the first thing is of course,

15
00:00:33,260 --> 00:00:37,830
‫this method here which is now not patch, but delete.

16
00:00:37,830 --> 00:00:38,663
‫Okay?

17
00:00:38,663 --> 00:00:40,810
‫Then we still need to pass in an ID

18
00:00:40,810 --> 00:00:43,440
‫for the tour that we actually want to delete.

19
00:00:43,440 --> 00:00:46,220
‫And then let's also change our response.

20
00:00:46,220 --> 00:00:48,220
‫So when we have a delete request,

21
00:00:48,220 --> 00:00:50,933
‫the response is usually a 204.

22
00:00:51,910 --> 00:00:54,500
‫And 204 means no content.

23
00:00:54,500 --> 00:00:56,760
‫And so that's because, as a result,

24
00:00:56,760 --> 00:00:59,550
‫we usually don't sent any data back.

25
00:00:59,550 --> 00:01:02,630
‫Instead, we just sent null, okay?

26
00:01:02,630 --> 00:01:06,500
‫So the status is still a success, but the data is null,

27
00:01:06,500 --> 00:01:08,860
‫simply to show that the resource that we deleted

28
00:01:08,860 --> 00:01:10,450
‫now no longer exists.

29
00:01:10,450 --> 00:01:12,660
‫So that is what null means.

30
00:01:12,660 --> 00:01:13,590
‫Okay?

31
00:01:13,590 --> 00:01:15,460
‫So pretty similar to patch,

32
00:01:15,460 --> 00:01:18,020
‫the difference here, in this case here,

33
00:01:18,020 --> 00:01:20,750
‫is that we change the delete method,

34
00:01:20,750 --> 00:01:24,990
‫we change the status code to no content, which is 204,

35
00:01:24,990 --> 00:01:27,670
‫and the data that we send back is null.

36
00:01:27,670 --> 00:01:29,510
‫Okay, and so even in the real world,

37
00:01:29,510 --> 00:01:32,543
‫that is exactly the response that we're gonna send back.

38
00:01:33,650 --> 00:01:37,693
‫Okay, so now all we have to do go, ahead and test it out.

39
00:01:40,030 --> 00:01:42,723
‫And using of course, delete.

40
00:01:44,280 --> 00:01:47,833
‫Let me also save it here as delete tour.

41
00:01:52,320 --> 00:01:55,120
‫And so let's pretend that we want to delete

42
00:01:55,120 --> 00:01:56,773
‫tour number seven.

43
00:01:57,710 --> 00:01:59,710
‫Again, that's not gonna do anything.

44
00:01:59,710 --> 00:02:02,630
‫And so here we have our tool for no content.

45
00:02:02,630 --> 00:02:06,340
‫And actually, Postman then indeed shows us here

46
00:02:06,340 --> 00:02:07,680
‫no content at all.

47
00:02:07,680 --> 00:02:10,600
‫So it doesn't even show us the adjacent that we sent back.

48
00:02:10,600 --> 00:02:13,340
‫It simply gives us 204 no content.

49
00:02:13,340 --> 00:02:14,173
‫Okay?

50
00:02:14,173 --> 00:02:15,513
‫So let's just save it here.

51
00:02:16,569 --> 00:02:18,330
‫We have it here on the left side now, as well.

52
00:02:18,330 --> 00:02:22,400
‫And you'll see that our collection here is steadily growing,

53
00:02:22,400 --> 00:02:24,430
‫so that's really cool.

54
00:02:24,430 --> 00:02:25,810
‫Now, in the next video

55
00:02:25,810 --> 00:02:29,120
‫we will actually make our code look a bit nicer.

56
00:02:29,120 --> 00:02:31,883
‫So organize it and follow some best practices

57
00:02:31,883 --> 00:02:34,693
‫to make our code a bit less messy.

