1
00:00:00,690 --> 00:00:06,720
I think we're moving in a nice pace, and up next, I'll actually work on the task.

2
00:00:06,740 --> 00:00:07,140
Why?

3
00:00:07,560 --> 00:00:13,770
Well, because with Updyke task, it's a bit more complicated and I kind of want to leave it as the

4
00:00:13,770 --> 00:00:20,320
last one because I promised you that I'll show you the differences between port and Patch as well.

5
00:00:20,580 --> 00:00:22,790
So therefore, let's work on the lead.

6
00:00:23,040 --> 00:00:25,560
Now, most of the stuff is going to be exactly the same.

7
00:00:25,570 --> 00:00:31,020
So once you're comfortable with the lead, I think you'll have no problem setting up update task as

8
00:00:31,020 --> 00:00:31,250
well.

9
00:00:31,860 --> 00:00:39,030
And just to showcase in our application, if we go back to all the tasks, if you click on removing

10
00:00:39,030 --> 00:00:40,380
the task, there you go.

11
00:00:40,620 --> 00:00:47,580
Of course, we just remove the task and the set up is going to be very, very similar to getting the

12
00:00:47,580 --> 00:00:49,050
task force course.

13
00:00:49,060 --> 00:00:53,760
The biggest difference is going to be the method more to function that we're going to use.

14
00:00:54,060 --> 00:00:57,940
And in this case, we're looking for find one and lead.

15
00:00:58,410 --> 00:01:00,910
But everything else pretty much is going to be the same.

16
00:01:01,140 --> 00:01:06,030
So if you want to go and just copy and paste in terms of hours, but in my case, since there's going

17
00:01:06,030 --> 00:01:09,060
to be a bit more productive, why don't we type it out together?

18
00:01:09,310 --> 00:01:14,090
So I'll go with my I think we go with try catch block.

19
00:01:14,430 --> 00:01:18,090
Now I have simple results and so I'll just remove it altogether.

20
00:01:18,420 --> 00:01:23,640
Then we want to look for that idea in the primes because again, setup isn't going to be exactly the

21
00:01:23,640 --> 00:01:30,260
same where we pass in the eddy with our primes and we'll call this task already.

22
00:01:30,690 --> 00:01:33,570
And that one is equal to Iraq DOT programs.

23
00:01:34,030 --> 00:01:41,010
Then once we have access to programs we just want to go with, const task is equal to a weight then

24
00:01:41,040 --> 00:01:48,290
task and then find one and remove or I'm sorry Delyth so find one undelete.

25
00:01:48,640 --> 00:01:51,560
And here we want to pass in the idea again.

26
00:01:51,780 --> 00:01:59,130
So on the security and that one is equal to our task and then ID and then once we have the set up of

27
00:01:59,130 --> 00:02:01,080
course then we have two options.

28
00:02:01,410 --> 00:02:08,240
If such a task exists then we send back our two hundred if the task doesn't exist.

29
00:02:08,250 --> 00:02:13,950
So essentially if this is equal to now, then of course we go with our four or four and in this case

30
00:02:13,950 --> 00:02:18,570
I will speed this up a little bit where I'll grab the if condition like so.

31
00:02:18,840 --> 00:02:26,160
And as far as the response initially, I'm going to go with adjacent object and I'll set task equal

32
00:02:26,160 --> 00:02:26,700
to task.

33
00:02:27,090 --> 00:02:31,240
But at the very end of the video, I'll discuss multiple options that we have.

34
00:02:31,500 --> 00:02:38,540
So this is the four or four, if we're not successful again, if that item doesn't exist with that particular,

35
00:02:39,270 --> 00:02:45,000
if we are successful, we go towards that and status and we pass them two hundred.

36
00:02:45,890 --> 00:02:51,590
And then we just go with Jason and then we pass in the task, so essentially that way in a post man

37
00:02:51,590 --> 00:02:54,680
will be able to see which task we removed.

38
00:02:55,070 --> 00:03:03,560
And then just like the previous controllers will grab our generic one as well and set it up in the catch

39
00:03:03,560 --> 00:03:03,800
one.

40
00:03:03,830 --> 00:03:08,860
So if there is an error, there's going to be a message property with that particular.

41
00:03:09,200 --> 00:03:14,350
So we navigate back to the postman and will unfortunately task again.

42
00:03:14,630 --> 00:03:16,100
We have this dummy value.

43
00:03:16,220 --> 00:03:20,060
In my case, that is Peter, but in your case it might be something else.

44
00:03:20,360 --> 00:03:24,590
So again, we need to go to get all tasks on it.

45
00:03:25,010 --> 00:03:30,270
So now, of course, we can see all our task and then just pick whichever you want to remove.

46
00:03:30,650 --> 00:03:36,740
And, you know, in my case, I'm going to go for those empty ones first because I don't want them in

47
00:03:36,740 --> 00:03:37,820
my database anyway.

48
00:03:38,240 --> 00:03:45,380
So I'll go over here, I'll grab the idea, and then I'm looking for the lead task copy and paste.

49
00:03:45,590 --> 00:03:51,860
And then once I say check it out now, of course, I can see that I removed this task and I'll remove

50
00:03:51,860 --> 00:03:53,170
another one as well.

51
00:03:53,180 --> 00:03:54,720
So let me run it one more time.

52
00:03:54,830 --> 00:04:00,320
Now I can clearly see that I have only one without a name since I removed the previous one.

53
00:04:00,750 --> 00:04:05,870
So let me just grab it over here and run back to the lead task.

54
00:04:06,260 --> 00:04:11,660
Copy and paste and send and of course, and clearly see that I removed this one as well.

55
00:04:11,990 --> 00:04:18,579
And just to showcase again why we have those two errors, let's go back to all the tasks, let's say,

56
00:04:18,589 --> 00:04:21,950
and I'll grab the first one for shake and bake.

57
00:04:22,550 --> 00:04:30,920
And what you'll notice is that if I pass in the idee and if I just change the last value so I still

58
00:04:30,920 --> 00:04:34,880
keep the same structure, then of course we'll get our four or four.

59
00:04:35,270 --> 00:04:36,920
So no task with it.

60
00:04:37,310 --> 00:04:38,990
And of course I have four or four.

61
00:04:39,230 --> 00:04:44,060
Now, if I'll start adding or removing the items.

62
00:04:44,600 --> 00:04:47,960
And of course, what you'll see is this error.

63
00:04:48,230 --> 00:04:52,520
Of course, this is coming from our cache, but hopefully that makes sense.

64
00:04:52,910 --> 00:04:58,190
And then lastly, I just want to mention that as far as this response, I purposely set it up here as

65
00:04:58,190 --> 00:05:05,420
a task just so we can see in the postman, because I think it's a bit useful when we setting up our

66
00:05:05,420 --> 00:05:06,500
first API.

67
00:05:06,890 --> 00:05:11,810
But by any means, you're not limited to sending this type of response.

68
00:05:11,810 --> 00:05:12,160
Why?

69
00:05:12,650 --> 00:05:18,790
Well, because usually when it comes to deleting a task, you're really not looking for the data here.

70
00:05:19,100 --> 00:05:20,540
Take a look at our fronton.

71
00:05:20,960 --> 00:05:27,170
It really doesn't care what task we're actually removing because the way the functionality works is

72
00:05:27,170 --> 00:05:30,410
I click on a button that I'm looking for response.

73
00:05:30,710 --> 00:05:39,260
And if the server sends back this two hundred, then right away on my front end I go like, OK, awesome,

74
00:05:39,380 --> 00:05:40,430
I was successful.

75
00:05:40,670 --> 00:05:43,160
So let me fetch the entire list one more time.

76
00:05:43,520 --> 00:05:46,970
So it's not like I take that item and then I do something about it.

77
00:05:47,060 --> 00:05:50,720
No, I just say I want to remove the item if I'm successful.

78
00:05:50,900 --> 00:05:51,500
Awesome.

79
00:05:51,770 --> 00:05:52,760
I'll do one thing.

80
00:05:53,000 --> 00:05:59,150
If I'm not successful then of course I want to display some error message or something along those lines.

81
00:05:59,420 --> 00:06:05,390
Therefore, if you go back and if you change this around you, for example, and I'll just show you

82
00:06:05,570 --> 00:06:08,540
some common ones that you might see in the other APIs.

83
00:06:08,810 --> 00:06:11,600
So if McCommon this one out, I'll copy and paste.

84
00:06:11,960 --> 00:06:16,880
And then as long as you go with two hundred, you can simply even go like this.

85
00:06:16,880 --> 00:06:17,750
You can say send.

86
00:06:17,870 --> 00:06:19,850
That's it, that's all you have to do.

87
00:06:20,090 --> 00:06:22,550
And the functionality will still work.

88
00:06:22,820 --> 00:06:30,290
Or you might see something like this, or you can copy and paste and then if we go it just on and some

89
00:06:30,290 --> 00:06:38,990
people just go with task and then set it equal to now and you might add a status property here we had

90
00:06:38,990 --> 00:06:46,760
success and as think the sky is the limit, I'm just showing you what type of responses you might get

91
00:06:46,760 --> 00:06:53,450
back, because, again, the main idea is that if you're successful, if you're getting these two hundred

92
00:06:53,870 --> 00:06:58,790
already on a front and you know what's happening, so most likely you're not going to be looking for

93
00:06:58,790 --> 00:07:02,390
that one specific item that you're deleting.

94
00:07:02,390 --> 00:07:08,570
But again, in my case, I just set up this task so we can actually see in a postman what we're doing.

95
00:07:08,870 --> 00:07:16,700
So I remove these two lines of code here and then I'll just set it back to my JSON where I have to task

96
00:07:16,970 --> 00:07:18,380
is equal to task.

97
00:07:18,650 --> 00:07:25,910
And as it works out, once we're done setting up of the update task group, I'll spend an entire video

98
00:07:26,150 --> 00:07:30,410
on various options that you have for your responses.

99
00:07:30,860 --> 00:07:35,090
So just put the pin on that and we'll come back to it a bit later.

