All right.
And up next, let's work on the edit job functionality and you'll notice that a lot of the functionality
is going to be similar to creating a job as well as getting a single job.
So let's go step by step.
First of all, the method we're looking for is the patch one.
So we're going to go with app dot Patch and yes, we'll have to have the same method when we're setting
up the Thunder client.
Now, when it comes to the URL, same deal.
We're looking for specific ID, correct.
Every time we want to update a specific job.
Well, we need that specific ID then also since we're updating.
The job will need two properties in the body.
We'll need the company as well as the position and the way we will set up if one of them is missing.
We'll ask the user to provide those values and therefore we'll set up a condition.
If one of them is missing, we'll send back for 100 and we'll say please provide company and position.
Then the idea again is located in rec dot params and we want to get the unique job.
Now if the ID is incorrect like we just saw in the previous video, again we'll send back this response
and if everything is correct then we'll update the job dot company.
Basically for this job over here as well as the position and we'll just send back dot status response
is 200 and then Json with some kind of message as well as the actual job.
And yes, in order to speed this up, I will copy and paste the values.
Otherwise, I mean, it's just going to take longer than I want to.
And now let's start by.
Setting up this one.
And as far as the comment, I'm going to go with edit job.
Now, the method, like I said, is going to be patch.
Then the URL stays the same.
And now let's just add the logic to check for company and position.
So let's take this copy.
Let's scroll down and then right above the req.params let me copy and paste this again.
We're looking for company in position.
If one of them is missing, we send back 400.
Then we grab the ID from Req.params.
We check for single job.
If that is missing, we send back 404.
So we're saying, Hey, listen, we cannot find this resource and if everything is correct, then we
go to job.
So that's going to be that single job in our array.
Then company.
So that's the value in a body.
And then we want to do the same thing pretty much here.
With the company.
Or I'm sorry, with the position.
And then let's keep on moving as far as the response status 200, and then basically we'll go here with
message and we'll say job modified.
And then let's provide the job.
Let's save it.
And once we have the functionality in place, we want to swing over to Thunder Client.
We want to duplicate it over here.
Let me right away rename it.
So I'm going to go here with edit job.
And essentially it's going to be a batch request, so not a get request.
A batch request.
And of course, since we're adding the code, we are restarting the server.
And since we're restarting the server again, we're going to go back to those two jobs.
So make sure that before you set up a edit job request.
You first grabbed those unique IDs like so.
So in this case, again, we're back to the Apple and Google.
We want to go to edit job.
We want to provide over here a valid ID and then we want to go back to create job and we want to grab
both of these things, the company and position.
So let's navigate to edit job.
We'll post over here in the body and if everything is correct, this is the response we should see.
And if we take a look at all the jobs instead of Apple and front end, now we have Facebook and DevOps.
So that's how we can successfully modify the existing resource on the server.