All right.
And up next, let's talk about status codes.
Library, which provides status codes as properties.
And as a result, there's a less chance for typos.
And also, at least in my opinion, it's easier to understand what's happening in your code.
Now, is it wrong to hard code every time?
The status code?
No.
But hopefully by the end of this video you'll see the benefits of the library.
Essentially, in order to install it, you want to run npm i http hyphen status hyphen codes and I just
provided the codes we're going to use in this project.
But of course if you navigate to their docs, you'll see way more options and essentially we import
the status codes from the library.
And then on this object we'll have a bunch of properties.
So for example, if we want to go 200, we're going to go with okay property.
If we want to go with 201, then we'll get created.
And these are just explanations of the status code.
So let's try this out.
We're going to go to job controller and for now we'll just fix the 201 and 200.
So we'll work on the 400 and fours in a second.
So don't refactor them right now.
I'm going to go with import.
We want to go here with status codes.
That's coming from the library.
And then one by one, let's change them.
So again, we're looking for status codes.
And like I said, they are properties and we right away see our options.
Like I said, there are quite a few of them, but.
I just provided in the Readme.
The ones we're going to use as far as the one we're going to go with, same thing.
And we're looking for created.
So as you can see, there's less chance for.
The typo.
And also, at least in my opinion, it's easier to see what's happening.
So in here, the response is okay.
And then.
For the great job we have created.
And let's keep on moving.
Same deal.
And you know what?
In order to speed this up, I'll just copy and paste.
So this is going to be okay.
Then we have over here.
Okay.
And this one will be okay as well.
And with this in place now, we can discuss custom error class.