1
00:00:00,050 --> 00:00:00,380
All right.

2
00:00:00,380 --> 00:00:02,900
And up next, let's talk about status codes.

3
00:00:02,930 --> 00:00:06,890
Library, which provides status codes as properties.

4
00:00:07,130 --> 00:00:12,440
And as a result, there's a less chance for typos.

5
00:00:12,740 --> 00:00:19,220
And also, at least in my opinion, it's easier to understand what's happening in your code.

6
00:00:19,370 --> 00:00:22,640
Now, is it wrong to hard code every time?

7
00:00:22,640 --> 00:00:23,540
The status code?

8
00:00:23,570 --> 00:00:24,110
No.

9
00:00:24,110 --> 00:00:28,760
But hopefully by the end of this video you'll see the benefits of the library.

10
00:00:28,880 --> 00:00:38,840
Essentially, in order to install it, you want to run npm i http hyphen status hyphen codes and I just

11
00:00:38,840 --> 00:00:41,840
provided the codes we're going to use in this project.

12
00:00:41,840 --> 00:00:48,200
But of course if you navigate to their docs, you'll see way more options and essentially we import

13
00:00:48,200 --> 00:00:51,890
the status codes from the library.

14
00:00:51,890 --> 00:00:55,250
And then on this object we'll have a bunch of properties.

15
00:00:55,250 --> 00:01:01,160
So for example, if we want to go 200, we're going to go with okay property.

16
00:01:01,250 --> 00:01:04,370
If we want to go with 201, then we'll get created.

17
00:01:04,370 --> 00:01:08,000
And these are just explanations of the status code.

18
00:01:08,000 --> 00:01:10,700
So let's try this out.

19
00:01:10,730 --> 00:01:17,750
We're going to go to job controller and for now we'll just fix the 201 and 200.

20
00:01:17,750 --> 00:01:21,290
So we'll work on the 400 and fours in a second.

21
00:01:21,290 --> 00:01:24,500
So don't refactor them right now.

22
00:01:24,560 --> 00:01:26,000
I'm going to go with import.

23
00:01:26,030 --> 00:01:29,300
We want to go here with status codes.

24
00:01:29,600 --> 00:01:31,400
That's coming from the library.

25
00:01:31,400 --> 00:01:34,640
And then one by one, let's change them.

26
00:01:34,640 --> 00:01:36,920
So again, we're looking for status codes.

27
00:01:36,920 --> 00:01:40,940
And like I said, they are properties and we right away see our options.

28
00:01:40,940 --> 00:01:43,550
Like I said, there are quite a few of them, but.

29
00:01:44,260 --> 00:01:45,680
I just provided in the Readme.

30
00:01:45,700 --> 00:01:50,850
The ones we're going to use as far as the one we're going to go with, same thing.

31
00:01:50,890 --> 00:01:52,800
And we're looking for created.

32
00:01:52,810 --> 00:01:56,350
So as you can see, there's less chance for.

33
00:01:57,440 --> 00:01:58,520
The typo.

34
00:01:58,550 --> 00:02:02,090
And also, at least in my opinion, it's easier to see what's happening.

35
00:02:02,090 --> 00:02:05,270
So in here, the response is okay.

36
00:02:05,270 --> 00:02:06,080
And then.

37
00:02:06,630 --> 00:02:08,940
For the great job we have created.

38
00:02:09,090 --> 00:02:10,570
And let's keep on moving.

39
00:02:10,590 --> 00:02:11,270
Same deal.

40
00:02:11,280 --> 00:02:12,090
And you know what?

41
00:02:12,270 --> 00:02:14,790
In order to speed this up, I'll just copy and paste.

42
00:02:15,720 --> 00:02:18,090
So this is going to be okay.

43
00:02:18,840 --> 00:02:19,890
Then we have over here.

44
00:02:19,920 --> 00:02:20,640
Okay.

45
00:02:21,120 --> 00:02:23,580
And this one will be okay as well.

46
00:02:23,760 --> 00:02:29,550
And with this in place now, we can discuss custom error class.

