1
00:00:00,210 --> 00:00:01,270
Not bad, not bad.

2
00:00:01,320 --> 00:00:08,310
Once we have discussed our response options, next, I want to work on a route not found.

3
00:00:08,790 --> 00:00:11,450
So at the moment, life is awesome.

4
00:00:11,760 --> 00:00:13,410
We have our application.

5
00:00:13,710 --> 00:00:14,870
Everything works.

6
00:00:14,880 --> 00:00:17,520
If I go to an mall, of course, I can see the application.

7
00:00:18,000 --> 00:00:24,090
If I go to API, then version one and then tasks because I can see all the tasks.

8
00:00:24,460 --> 00:00:29,220
What happens if I go with paper version one and then hello?

9
00:00:29,550 --> 00:00:32,790
So I have cannot get API, blah blah blah.

10
00:00:33,480 --> 00:00:40,590
And I can clearly see in my browser that of course we get for or for error, but essentially this is

11
00:00:40,590 --> 00:00:41,670
going to be the default one.

12
00:00:42,210 --> 00:00:46,250
And instead I want to set up the custom one just like they have it.

13
00:00:46,290 --> 00:00:47,910
And I'll go with one again.

14
00:00:48,240 --> 00:00:54,960
If you're looking for some kind of resource and the server can find the research and essentially we

15
00:00:54,960 --> 00:00:56,340
still get the four or four.

16
00:00:56,610 --> 00:00:59,370
But of course, the value here is unknown.

17
00:00:59,820 --> 00:01:02,840
It doesn't really matter what you set up as far as the value.

18
00:01:03,120 --> 00:01:08,520
Just want to showcase how we can set up a custom for for response.

19
00:01:09,000 --> 00:01:14,730
And the way we do that, we go back to our application here and then in the apgar's.

20
00:01:14,760 --> 00:01:23,040
I want to remove these comments because I think we're clear on our API and location here is very important.

21
00:01:23,230 --> 00:01:27,840
So we have the middleware for public andreassen that still stays the same.

22
00:01:28,260 --> 00:01:31,500
Then we have all our outs for the tasks.

23
00:01:31,920 --> 00:01:39,300
And then right after that we want to go with apps that use and then we'll pass in our middleware function,

24
00:01:39,570 --> 00:01:45,340
the one that will handle the photographer and send some kind of customer response.

25
00:01:45,600 --> 00:01:53,220
Now, we haven't created it yet, so let's go back to our starter will create a new folder because there's

26
00:01:53,220 --> 00:01:56,490
going to be a few middle words that will set up in the upcoming video.

27
00:01:56,500 --> 00:02:00,750
So say middleware and then side of the middleware.

28
00:02:01,080 --> 00:02:08,130
We want to go with new file and I'll call this one, not surprisingly, not found an address.

29
00:02:08,460 --> 00:02:12,750
And as far as the logic, well, we'll still have access to Iraq and arrays.

30
00:02:13,080 --> 00:02:14,880
So we just need to come up with function name.

31
00:02:14,880 --> 00:02:18,720
Neiman Marcus is going to be not found and I'll set it equal to Iraq.

32
00:02:19,030 --> 00:02:25,500
And and as far as the response, I'm just going to go with various dot then status.

33
00:02:25,860 --> 00:02:28,110
And of course, in this case, it's four or four.

34
00:02:28,140 --> 00:02:31,770
So the server is letting the user know that it cannot find the resource.

35
00:02:31,770 --> 00:02:39,810
And then as far as the message, I'll just use a simple send and I'll say it does not exist.

36
00:02:40,480 --> 00:02:47,190
So now, of course, we just need to explore this and we do that with module then exports, of course,

37
00:02:47,580 --> 00:02:50,190
and set it equal to are not found.

38
00:02:50,460 --> 00:02:57,330
And then back in the abcess above the Abduallah, I guess we're going to go with Consed.

39
00:02:57,330 --> 00:03:00,630
Not found is equal to require.

40
00:03:01,540 --> 00:03:09,100
Than we're looking, of course, in our law, so let me say that more and more specifically, we're

41
00:03:09,100 --> 00:03:16,110
looking in the not found and in the app that use will just stick, not found one.

42
00:03:16,330 --> 00:03:21,550
And once we save and in this case, I'll just use the postman just so I can see that it's going to work

43
00:03:21,550 --> 00:03:22,380
exactly the same.

44
00:03:22,720 --> 00:03:27,400
And if we're looking for the URL and then we'll go with hello.

45
00:03:27,750 --> 00:03:33,940
Of course we have our custom one we have we're out of does not exist, which is pretty awesome.

46
00:03:33,940 --> 00:03:38,320
And just to show us that it's going to be the same scenario in the browser as well.

47
00:03:39,130 --> 00:03:42,990
Once we refresh, we have we're out does not exist.

48
00:03:43,000 --> 00:03:45,490
So we set up the middleware folder in there.

49
00:03:45,500 --> 00:03:47,350
We have not found Jairus.

50
00:03:47,590 --> 00:03:51,250
And then back in the objects, we import a function.

51
00:03:51,640 --> 00:03:54,430
We set some kind of name I it's not found.

52
00:03:54,730 --> 00:04:00,580
And then all the way in the bottom, we go with abduct use and we pass in the function.

53
00:04:00,850 --> 00:04:05,010
And in that function we'll have access to rec and rise.

54
00:04:05,260 --> 00:04:12,610
And in our case we're just interested in response and we'll set up a 404 with whatever message we want

55
00:04:12,610 --> 00:04:13,210
to send back.

