Hi everyone.
In this video I will show you how we can return in the best way using the concept of veto and use the
interceptor.
Okay, right here inside the RC folder I will create one more folder will be underscore cross.
Okay, these are the cross for the new for the interceptor.
And maybe in the future we will have a middleware okay.
Or girls or something like that.
Okay.
The reason I put it inside the car because it will organize the code.
Okay.
And I want most many things right here outside the root folder or the src folder okay.
It will be messy with the other module, so I will move that into the course.
And right now let's go to the interceptor.
So here let's create interceptor.
We will jump from radio Interceptor and move over here and make sure we install the class transformer.
Okay.
Now let's see how we can install that.
If you remember in the first section of the video on the core concept of the session, I already showed
you the validation.
That is right.
In here we have a class validator and class transformer.
For now let's install.
That's does also.
Now, if you do not understand what the god's over here, but please go back and watch the section about
the legit fundamental.
Okay.
Now we have an error.
Let me say.
Right here we have.
Error from S linked.
Well two error.
Firstly let me show you how we can fit us.
Click here and click on show documentation and open that.
In here let me copy the rule upstairs.
And go to the eslint config.
Okay.
And start over here.
And gentle off.
It will fix one error and we have another error from the return.
You can see you can read.
Error will be no unsafe returns right.
Right here.
Let's change.
The return will be off and this will be work.
So.
After we already have a transform right here, let me show you how it can be used inside this zero.
Here of the authentication I will create a small authentication with your lost keys.
Right.
In here.
What do we need to do?
I will export a class.
We will respond.
How little?
Right here I will expose name.
Email.
Okay.
We only missed two.
Pieces.
Here.
Um, let me remove everything.
I just need to return the blacklist.
This thing.
Well, right now, let's do that.
Use interceptor.
We will.
Let me say, what is the name we will import from this year over here?
And most of babies born on this year.
Okay.
And we have an error.
The reason?
Because right here, we just need to move it over here.
Okay.
And let's say it were not.
Now you can say it's already got the name and email.
Okay.
And one more thing.
We should return, which is the message okay.
And what it will return the message will be success.
And after that the type of data.
So in order to do that go back to the transform radio interceptor.
Let me close this line.
Okay.
So let me say Here we would say success, right?
And we put the data we plan to test.
Okay.
And now we have one more TypeScript error.
Let this border also.
Okay.
This will fix.
And let me show you over here.
Create a new team and say okay, we already got the data message and data.
Very good.
So that's for the video.
And I will see you in the next one.