It's time for us to make our first requests from the client side, and that is from the browser.
Under the API development, we always make a request using this tool called ten dot client and it always
give us JSON data.
So how are we going to make a request from the client side?
The process is going to be the same, meaning that we need to pass in the properties that we need.
So how are we going to pass this data from the client side?
So the question is how can we make the same request from the client side?
Let me show you how.
Let's get into the register template.
That's where we want to make the request.
So we inside the.
Controllers, users.
And here we go.
Let's start with the register.
For this one, we will do fuel refraction, because for this one, we are going to retain energies in
data.
But I will show you when we get there.
So the next question is that how can we have access to the data a user is sending from the client side?
So let's open the form and that is users and the register template of form.
And this is a form when I collapse age, you can see that this is the actual form.
And this form we have additional attribute.
One is the action.
Action simply means the endpoint that we want to hit.
In our case, we want to hit this API endpoint to register the next one going to be the method, meaning
what HTTP method do you want to use?
And for this we are going to use post as we did when using the ten client.
So the concept is going to be the same.
So the you are is going to be as this.
So I'll copy this one and back to the form.
The action will point to this.
Then the method is this one.
Now we are done with this ones.
The next question is how can we pass this payload from the browser?
That's why we have a name attribute inside the input.
So whatever we pass in here, we hold the actual value and what we passing here must be equally as the
way we are calling the endpoint here, or it might be the same as the properties on the module and which
are the full name, email and password.
So let's see how we are going to implement that.
So now back to the form, the first one going to be the full name.
We could ask what is specified on this schema and for this I'm going to remove the ID.
Likewise, the email is going to be the email.
Let me remove this one and then the password.
It remains the same as the password.
The next step is that make sure you have a type or submit on the button.
So now with this one, when I make a request, I'll be able to register a moment of truth.
So back to the controller.
Let's go ahead and console.log the red dot body and let's see what we're going to get.
All right.
And for this, too, I want to console.log the response that came back after registration.
So I'm going to be as constituted log the actual user being registered.
Moment of truth.
So let's get back to the form.
Refresh it.
Let me open the console, click on console and let me click on this one.
And now I have clean sheet of my console.
So the first one going to be full name and I'll call this one as Thomas.
And then email as us.
At gmail.com.
The password.
One, two, three, four, five.
Hit send.
Now you can see all fields are required, meaning that I am not passing in some data.
So let's check again.
So back to the controller.
Let's see what we are not passing in.
Well, we have full name, email and password.
You can see that we're able to hit the endpoint, but we are not passing in the actual data.
Remember when we are trying to send data to our endpoints using existing data, unless you configure
our express server to be able to parse incoming data and this is a code to get it done the same way.
If we are trying to access a data from a form, unless we tell Express to do that.
So here we go, we're going to be app dot use and we're going to use express dot.
You are encoded as a function call and then the additional configuration and extend that to true.
With this one, we'll be able to have the data we are sending from the browser on the red dot body.
This one is for passing JSON data.
So because we are not dealing with API anymore, I can go ahead and remove this one, but let me maintain
it and let me add a comment as passed for data.
So now with this one less refresh it and let's make the request again.
Let me provide Ben and then email as Ben at gmail.com.
Password one, two, three, four, five.
Hit, send or register.
And we got some beautiful message and that is of success and full name, band, email and meaning that
I was able to register successfully.
If I check the terminal, I'm going to see the user being registered.
And there we go.
This is a user and this is a payload.
So that is it about the registration.
But what I want to do is that after a user is registered, I want to retract the user after registration.
Let's get into that in the next video.