Hi, everyone.
Let's work with the model.
Actually, I typo wrong right here.
This model.
Okay, there it is.
And now let me use.
Let me remove right here because I already hardcode that right.
I don't want that.
So I will pass the data right here and right now I will pass it will be the any right now.
And I will replace that with data.
So how we can do that inside a controller?
It's already error, right.
Because we we must pass data.
Right.
And in the post right here I want create a body with the raw and the JSON okay.
I want to pass something like this title.
Post 2, right.
Description.
Post 2
Description.
So how we can do that, inside the create right here.
I will use something called annotation.
Sorry.
I will use the decorator.
We will call @Body and I will call this will be requestBody
And I will typo
I will type any right now and I will comment and I will console.log.
What is the request body?
Okay.
Let's wait a bit.
Okay, now let me see.
Now you can see it already.
Console.log.
For me the title and description.
Right? Thank to the @Body
If we don't use the body, let's see.
I will send this will be the undefined right?
For that reason, make sure we use the annotation.
Sorry I because I got the Java.
So I use the term like "annotation".
But this will call "decorator" in typescript
This will call the decorator.
Okay.
So I will pass the request body into the create.
And that is.
Let me send.
Okay.
That's it
created
And, let's check the database.
Let me refresh.
Now we have a "post 2", right?
Very cool
And if you want
If you want data type for this, we can create something like "interface", right?
But right now, let me show you what's inside the post document right here.
If I use the post document.
Now, if I.
If I go to the requestBody
I will dot.
It have a many, many thing.
For example title.
Right? requestBody.description, It's already have some data like this.
So we can reuse that.
But I will show you another way later.
Don't worry about that.
That's a not good way.
Okay.
We can see post documentation.
And if I create.
Okay.
This work.
Right?
This work.
Right here.
But this is not good.
Way
And in the next video, I will show you the concept of "DTO".
So see you in the next one.