1
00:00:00,180 --> 00:00:06,150
All right, so far in our application, every time we need a status code, we just type the numbers

2
00:00:06,150 --> 00:00:08,189
out, which is kind of OK.

3
00:00:08,189 --> 00:00:15,060
But there's actually a better approach, not a better approach is using the library by the name of HTTP

4
00:00:15,240 --> 00:00:16,470
status codes.

5
00:00:16,890 --> 00:00:18,970
And of course, we need to install a library.

6
00:00:19,350 --> 00:00:22,680
So this is the code if you need it for your own project, Mike.

7
00:00:22,710 --> 00:00:26,300
And of course, I already installed in a star, so that's why it's available.

8
00:00:26,700 --> 00:00:33,100
And then we simply want to get the status codes from the library online.

9
00:00:33,390 --> 00:00:34,350
This is an object.

10
00:00:34,350 --> 00:00:39,330
And then as far as the properties, we just need to look for the text values.

11
00:00:39,600 --> 00:00:42,970
For example, for two hundred, we're going to go with OK.

12
00:00:43,320 --> 00:00:48,240
Now, if you want to take a look at the codes, of course, just keep on scrolling and you'll notice

13
00:00:48,240 --> 00:00:52,620
that if we want to go with two hundred response, of course, then we just type OK.

14
00:00:53,010 --> 00:00:58,980
If we want to go with that request, then we just type it and this is going to be four hundred and hopefully

15
00:00:58,980 --> 00:00:59,690
you get the gist.

16
00:01:00,150 --> 00:01:03,450
And as a result we will accomplish two things.

17
00:01:03,960 --> 00:01:10,440
It going to be easier to understand what is happening as far as our responses instead of juggling the

18
00:01:10,440 --> 00:01:13,290
four hundreds and four ones and all that in your head.

19
00:01:13,380 --> 00:01:16,010
On a second thing, of course, we'll have more consistency.

20
00:01:16,350 --> 00:01:17,310
So let's try it out.

21
00:01:17,600 --> 00:01:21,840
And in this video, just try it out here in the our classes.

22
00:01:22,110 --> 00:01:28,450
And then, of course, in next video, one will be refactoring our code since, of course, we have

23
00:01:28,450 --> 00:01:33,440
a different set of errors, then we'll also implement those status codes there as well.

24
00:01:33,900 --> 00:01:39,650
And where we want to do is go to the bad request online, below or above the customer appear.

25
00:01:40,050 --> 00:01:42,090
Again, this part doesn't really matter.

26
00:01:42,360 --> 00:01:44,280
We're just going to go online.

27
00:01:44,280 --> 00:01:46,740
We're looking for status codes now.

28
00:01:46,740 --> 00:01:48,110
This is a name, the import.

29
00:01:48,240 --> 00:01:55,710
So make sure that the name is exactly the same status codes and then that one is coming from our library

30
00:01:55,860 --> 00:01:57,510
HTP status codes.

31
00:01:57,810 --> 00:02:03,390
And then instead of this four hundred, we're going to go with status codes and then we're just going

32
00:02:03,390 --> 00:02:05,190
to be looking for that request.

33
00:02:05,250 --> 00:02:08,370
Notice how they write away and give you all of these suggestions.

34
00:02:08,370 --> 00:02:10,410
Again, it's easier to read.

35
00:02:10,410 --> 00:02:12,230
It's easier to understand what is happening.

36
00:02:12,540 --> 00:02:14,550
And second, will have the consistency.

37
00:02:14,820 --> 00:02:19,020
And we want to do the same thing in unauthenticated as well.

38
00:02:19,410 --> 00:02:21,990
So let's navigate to this file again.

39
00:02:21,990 --> 00:02:24,630
We'll copy and paste just so we can speed this up.

40
00:02:25,110 --> 00:02:27,480
So copy and paste, we get the status codes.

41
00:02:27,750 --> 00:02:33,810
And in this case, of course, we're not looking for the request which one we're looking for on authorized.

42
00:02:34,110 --> 00:02:40,620
So let's go over here and say status codes, dot online, 140 forty on authorized one.

43
00:02:40,890 --> 00:02:45,300
And once we have fixed of the error classes using the status codes.

44
00:02:45,600 --> 00:02:51,420
Now, of course, we just need to hop back to our application and refactor it since, of course, our

45
00:02:51,420 --> 00:02:53,580
error handling has changed as well.

