1
00:00:05,980 --> 00:00:09,820
Welcome back to our first coding challenge.

2
00:00:09,820 --> 00:00:12,160
So let's see what we are going to do.

3
00:00:12,700 --> 00:00:22,150
It says that create a measure that will log the request method, the you are arrow and the date and

4
00:00:22,150 --> 00:00:24,490
time of the request.

5
00:00:24,850 --> 00:00:26,590
All right, give it a shot.

6
00:00:26,590 --> 00:00:29,620
When you finish, I will show you my solution.

7
00:00:42,140 --> 00:00:46,020
Let me show you how I'm going to solve this particular challenge.

8
00:00:46,040 --> 00:00:47,900
So it's a logger, right?

9
00:00:47,930 --> 00:00:54,350
I'm going to be the same as what we did for the first one as a logger, but instead we are going to

10
00:00:54,350 --> 00:00:57,590
display different texts or message.

11
00:00:57,590 --> 00:00:58,670
So here we go.

12
00:00:58,670 --> 00:01:05,090
So const, I will call this one logger and then equal to a new function.

13
00:01:05,090 --> 00:01:06,530
And here we go.

14
00:01:06,740 --> 00:01:10,640
I have already commented this one out, the first one called Logger.

15
00:01:10,670 --> 00:01:14,180
That is why I'm able to use the name of this logger.

16
00:01:14,210 --> 00:01:15,680
You can name it whatever you want.

17
00:01:15,680 --> 00:01:20,780
So we have accessed the requests and then the response and then the next.

18
00:01:21,230 --> 00:01:25,790
So now the challenge is that console.log, look what the request method.

19
00:01:25,790 --> 00:01:27,860
So how can we get the request method?

20
00:01:27,860 --> 00:01:35,060
So because we have access to the request object, we have all the properties on the request object.

21
00:01:35,060 --> 00:01:39,980
So here we go, let's call it next here before we start our logic.

22
00:01:39,980 --> 00:01:46,910
So now here comes, let's say message is equal to on the request.

23
00:01:46,910 --> 00:01:53,630
We have the HTTP method as the method and we have the you are error as you are error.

24
00:01:53,630 --> 00:01:56,990
So let me console.log that before I will show you what I mean.

25
00:01:56,990 --> 00:02:01,930
So req save it and now let's pass into app.

26
00:02:01,940 --> 00:02:07,300
Don't use meaning any of the routes we want to call this so logger is done.

27
00:02:07,310 --> 00:02:09,710
So now back to postman.

28
00:02:09,710 --> 00:02:11,660
Let me hit any of this endpoint.

29
00:02:11,660 --> 00:02:15,920
It doesn't exist because I think I have commented those ones out.

30
00:02:15,920 --> 00:02:17,990
So let me go to homepage.

31
00:02:19,720 --> 00:02:22,030
Any of the routes you send.

32
00:02:22,060 --> 00:02:26,600
Now check the console and the one that I want is the method.

33
00:02:26,620 --> 00:02:29,660
So if you scroll up, we're going to see the method.

34
00:02:29,680 --> 00:02:32,830
So on that, let me console.log it quickly here.

35
00:02:32,860 --> 00:02:36,250
So red dot method.

36
00:02:37,590 --> 00:02:38,400
Save it.

37
00:02:38,400 --> 00:02:46,920
Now let's make the request again and now and check the terminal here and see I get get method because

38
00:02:46,920 --> 00:02:48,840
that's what I use here.

39
00:02:49,350 --> 00:02:51,340
The next one is a u r.

40
00:02:51,390 --> 00:03:00,150
I can also get a you are I'll that so let's make the requests hit send check the terminal and I see

41
00:03:00,150 --> 00:03:06,780
it for a slash blue code is what I have requested for if I make it so forward, slash anything here

42
00:03:06,810 --> 00:03:08,730
because it doesn't exist.

43
00:03:08,730 --> 00:03:12,360
I still see the path being what console.log.

44
00:03:12,540 --> 00:03:12,900
Okay.

45
00:03:12,900 --> 00:03:16,140
So now I have access to the url and the method.

46
00:03:16,140 --> 00:03:17,550
So what about the date?

47
00:03:17,550 --> 00:03:20,490
And you can use JavaScript to get a date.

48
00:03:20,490 --> 00:03:23,160
So back to my code.

49
00:03:23,790 --> 00:03:24,780
Here we go.

50
00:03:24,930 --> 00:03:26,070
How to get a date.

51
00:03:26,100 --> 00:03:28,110
Make use of new date.

52
00:03:28,710 --> 00:03:32,340
New Date.

53
00:03:32,340 --> 00:03:37,230
And then as a function on that I want to convert to ISO string.

54
00:03:37,230 --> 00:03:40,800
So it's going to be two ISO string.

55
00:03:40,890 --> 00:03:44,850
I start now let me make the request again.

56
00:03:45,120 --> 00:03:46,710
Let me hit the right endpoint.

57
00:03:46,710 --> 00:03:50,790
It sends check the console and I get the date and time.

58
00:03:50,790 --> 00:03:55,320
So with this one I can go ahead and console.log the message.

59
00:03:55,320 --> 00:03:56,430
So here we go.

60
00:03:56,430 --> 00:04:03,570
And I will say that dollar sign Kerberos is going to be rec dot method.

61
00:04:04,910 --> 00:04:13,790
And then after that I want to get the euro dollar sign carried, which is red dot euro and then dash

62
00:04:13,790 --> 00:04:14,750
the debt.

63
00:04:14,780 --> 00:04:20,690
So dollar sign, carry basis and new date.

64
00:04:22,019 --> 00:04:26,820
Then as a function and dot to iso string and that is it.

65
00:04:26,820 --> 00:04:29,790
So if I make a request, let's see it.

66
00:04:29,790 --> 00:04:33,950
St check the terminal I get undefined.

67
00:04:33,960 --> 00:04:39,630
I think there is something wrong with what I did or is method as that.

68
00:04:39,630 --> 00:04:46,260
Sorry guys and red dot you are l so let's save it and now check it.

69
00:04:46,290 --> 00:04:50,310
You see I get the HTTP method and then the path.

70
00:04:50,310 --> 00:04:52,500
So this is the solution.

