1
00:00:00,170 --> 00:00:00,740
All right.

2
00:00:00,740 --> 00:00:07,910
And up next, let's work on the edit job functionality and you'll notice that a lot of the functionality

3
00:00:07,910 --> 00:00:13,970
is going to be similar to creating a job as well as getting a single job.

4
00:00:13,970 --> 00:00:15,320
So let's go step by step.

5
00:00:15,320 --> 00:00:18,620
First of all, the method we're looking for is the patch one.

6
00:00:18,620 --> 00:00:26,090
So we're going to go with app dot Patch and yes, we'll have to have the same method when we're setting

7
00:00:26,090 --> 00:00:27,650
up the Thunder client.

8
00:00:27,680 --> 00:00:31,280
Now, when it comes to the URL, same deal.

9
00:00:31,310 --> 00:00:34,820
We're looking for specific ID, correct.

10
00:00:34,820 --> 00:00:37,280
Every time we want to update a specific job.

11
00:00:37,280 --> 00:00:41,900
Well, we need that specific ID then also since we're updating.

12
00:00:42,700 --> 00:00:46,370
The job will need two properties in the body.

13
00:00:46,390 --> 00:00:52,360
We'll need the company as well as the position and the way we will set up if one of them is missing.

14
00:00:53,460 --> 00:00:58,470
We'll ask the user to provide those values and therefore we'll set up a condition.

15
00:00:58,470 --> 00:01:04,349
If one of them is missing, we'll send back for 100 and we'll say please provide company and position.

16
00:01:04,530 --> 00:01:13,270
Then the idea again is located in rec dot params and we want to get the unique job.

17
00:01:13,290 --> 00:01:20,520
Now if the ID is incorrect like we just saw in the previous video, again we'll send back this response

18
00:01:20,520 --> 00:01:26,520
and if everything is correct then we'll update the job dot company.

19
00:01:26,700 --> 00:01:33,690
Basically for this job over here as well as the position and we'll just send back dot status response

20
00:01:33,690 --> 00:01:40,760
is 200 and then Json with some kind of message as well as the actual job.

21
00:01:40,770 --> 00:01:44,670
And yes, in order to speed this up, I will copy and paste the values.

22
00:01:44,670 --> 00:01:49,170
Otherwise, I mean, it's just going to take longer than I want to.

23
00:01:49,350 --> 00:01:51,180
And now let's start by.

24
00:01:52,170 --> 00:01:53,460
Setting up this one.

25
00:01:53,460 --> 00:01:57,300
And as far as the comment, I'm going to go with edit job.

26
00:01:57,420 --> 00:02:00,300
Now, the method, like I said, is going to be patch.

27
00:02:01,940 --> 00:02:04,460
Then the URL stays the same.

28
00:02:04,550 --> 00:02:10,840
And now let's just add the logic to check for company and position.

29
00:02:10,850 --> 00:02:13,370
So let's take this copy.

30
00:02:13,520 --> 00:02:19,280
Let's scroll down and then right above the req.params let me copy and paste this again.

31
00:02:19,520 --> 00:02:21,140
We're looking for company in position.

32
00:02:21,140 --> 00:02:24,590
If one of them is missing, we send back 400.

33
00:02:24,890 --> 00:02:28,570
Then we grab the ID from Req.params.

34
00:02:28,580 --> 00:02:31,340
We check for single job.

35
00:02:31,340 --> 00:02:34,940
If that is missing, we send back 404.

36
00:02:35,150 --> 00:02:41,510
So we're saying, Hey, listen, we cannot find this resource and if everything is correct, then we

37
00:02:41,510 --> 00:02:42,660
go to job.

38
00:02:42,680 --> 00:02:45,620
So that's going to be that single job in our array.

39
00:02:45,740 --> 00:02:46,910
Then company.

40
00:02:48,120 --> 00:02:50,520
So that's the value in a body.

41
00:02:50,520 --> 00:02:54,540
And then we want to do the same thing pretty much here.

42
00:02:55,270 --> 00:02:56,410
With the company.

43
00:02:57,470 --> 00:02:59,210
Or I'm sorry, with the position.

44
00:02:59,330 --> 00:03:08,780
And then let's keep on moving as far as the response status 200, and then basically we'll go here with

45
00:03:08,780 --> 00:03:11,630
message and we'll say job modified.

46
00:03:13,280 --> 00:03:15,200
And then let's provide the job.

47
00:03:17,190 --> 00:03:18,060
Let's save it.

48
00:03:18,060 --> 00:03:23,820
And once we have the functionality in place, we want to swing over to Thunder Client.

49
00:03:24,120 --> 00:03:26,340
We want to duplicate it over here.

50
00:03:26,370 --> 00:03:28,350
Let me right away rename it.

51
00:03:28,800 --> 00:03:31,080
So I'm going to go here with edit job.

52
00:03:31,410 --> 00:03:37,020
And essentially it's going to be a batch request, so not a get request.

53
00:03:37,050 --> 00:03:38,190
A batch request.

54
00:03:38,370 --> 00:03:42,960
And of course, since we're adding the code, we are restarting the server.

55
00:03:42,960 --> 00:03:48,320
And since we're restarting the server again, we're going to go back to those two jobs.

56
00:03:48,330 --> 00:03:53,130
So make sure that before you set up a edit job request.

57
00:03:53,790 --> 00:03:57,720
You first grabbed those unique IDs like so.

58
00:03:57,720 --> 00:04:01,290
So in this case, again, we're back to the Apple and Google.

59
00:04:01,320 --> 00:04:02,850
We want to go to edit job.

60
00:04:02,850 --> 00:04:11,910
We want to provide over here a valid ID and then we want to go back to create job and we want to grab

61
00:04:11,910 --> 00:04:14,730
both of these things, the company and position.

62
00:04:14,910 --> 00:04:17,160
So let's navigate to edit job.

63
00:04:17,620 --> 00:04:22,860
We'll post over here in the body and if everything is correct, this is the response we should see.

64
00:04:22,980 --> 00:04:29,940
And if we take a look at all the jobs instead of Apple and front end, now we have Facebook and DevOps.

65
00:04:29,940 --> 00:04:37,320
So that's how we can successfully modify the existing resource on the server.

