WEBVTT

1
00:00.770 --> 00:02.510
Hi, everyone.

2
00:03.500 --> 00:10.040
Let's work with the model.

3
00:10.370 --> 00:12.620
Actually, I typo wrong right here.

4
00:13.220 --> 00:14.330
This model.

5
00:15.500 --> 00:17.780
Okay, there it is.

6
00:19.400 --> 00:23.000
And now let me use.

7
00:25.160 --> 00:31.760
Let me remove right here because I already hardcode that right.

8
00:31.790 --> 00:32.720
I don't want that.

9
00:32.720 --> 00:39.440
So I will pass the data right here and right now I will pass it will be the any right now.

10
00:40.280 --> 00:42.500
And I will replace that with data.

11
00:43.160 --> 00:47.180
So how we can do that inside a controller?

12
00:47.210 --> 00:49.220
It's already error, right.

13
00:49.220 --> 00:51.560
Because we we must pass data.

14
00:52.910 --> 00:53.480
Right.

15
00:53.660 --> 01:01.220
And in the post right here I want create a body with the raw and the JSON okay.

16
01:01.250 --> 01:03.470
I want to pass something like this title.

17
01:05.970 --> 01:07.620
Post 2, right.

18
01:09.000 --> 01:10.230
Description.

19
01:12.660 --> 01:13.500
Post 2

20
01:13.530 --> 01:14.400
Description.

21
01:14.850 --> 01:21.180
So how we can do that,  inside the create right here.

22
01:21.570 --> 01:26.400
I will use something called annotation.

23
01:26.430 --> 01:26.940
Sorry.

24
01:27.090 --> 01:28.860
I will use the decorator.

25
01:28.890 --> 01:34.890
We will call @Body and I will call this will be requestBody

26
01:35.040 --> 01:37.500
And I will typo

27
01:40.500 --> 01:45.540
I will type any right now and I will comment and I will console.log.

28
01:45.570 --> 01:47.190
What is the request body?

29
01:48.300 --> 01:48.840
Okay.

30
02:00.900 --> 02:02.910
Let's wait a bit.

31
02:12.100 --> 02:14.590
Okay, now let me see.

32
02:17.050 --> 02:18.670
Now you can see it already.

33
02:19.480 --> 02:20.470
Console.log.

34
02:20.470 --> 02:22.420
For me the title and description.

35
02:22.450 --> 02:24.580
Right? Thank to the @Body

36
02:24.640 --> 02:28.090
If we don't use the body, let's see.

37
02:32.860 --> 02:36.550
I will send this will be the undefined right?

38
02:36.580 --> 02:39.970
For that reason, make sure we use the annotation.

39
02:40.990 --> 02:46.540
Sorry I because I got the Java.

40
02:46.540 --> 02:50.200
So I use the term like "annotation".

41
02:50.200 --> 02:54.370
But this will call "decorator" in typescript

42
02:54.670 --> 02:56.590
This will call the decorator.

43
02:57.820 --> 02:58.390
Okay.

44
03:01.930 --> 03:07.390
So I will pass the request body into the create.

45
03:07.390 --> 03:08.620
And that is.

46
03:14.450 --> 03:15.080
Let me send.

47
03:17.120 --> 03:17.510
Okay.

48
03:17.540 --> 03:18.230
That's it

49
03:18.320 --> 03:18.830
created

50
03:18.950 --> 03:22.070
And, let's check the database.

51
03:23.210 --> 03:24.770
Let me refresh.

52
03:32.000 --> 03:34.520
Now we have a "post 2", right?

53
03:35.390 --> 03:36.080
Very cool

54
03:36.650 --> 03:38.660
And if you want

55
03:41.510 --> 03:49.880
If you want data type for this, we can create something like "interface", right?

56
03:50.390 --> 03:58.190
But right now, let me show you what's inside the post document right here.

57
03:58.700 --> 04:00.680
If I use the post document.

58
04:02.780 --> 04:03.620
Now, if I.

59
04:03.740 --> 04:06.260
If I go to the requestBody

60
04:09.170 --> 04:09.770
I will dot.

61
04:10.160 --> 04:12.230
It have a many, many thing.

62
04:13.190 --> 04:14.720
For example title.

63
04:14.720 --> 04:23.130
Right? requestBody.description, It's already have some data like this.

64
04:23.130 --> 04:24.900
So we can reuse that.

65
04:27.690 --> 04:30.210
But I will show you another way later.

66
04:30.330 --> 04:31.350
Don't worry about that.

67
04:31.380 --> 04:33.210
That's a not good way.

68
04:35.430 --> 04:35.910
Okay.

69
04:35.910 --> 04:39.540
We can see post documentation.

70
04:43.770 --> 04:45.120
And if I create.

71
04:54.420 --> 04:54.900
Okay.

72
04:55.950 --> 04:56.550
This work.

73
04:56.550 --> 04:56.940
Right?

74
04:57.600 --> 04:58.170
This work.

75
05:08.790 --> 05:09.390
Right here.

76
05:09.660 --> 05:11.040
But this is not good.

77
05:11.040 --> 05:11.460
Way

78
05:11.460 --> 05:16.410
And in the next video, I will show you the concept of "DTO".

79
05:16.440 --> 05:18.690
So see you in the next one.