In this video, let's implement the logic for fetching the profile of a user so inside the controller,
and that's for the user.
Let's go ahead and then make the logic.
Let's collapse the log in.
We are done with that.
And this is the profile for the profile.
You can see that we are passing the ID of the login user into the user as a and I don't want that.
So we have the looking user and the rec session and that is the ID, so we can use that one to make
a request, our database to find the log in user.
So here we go.
So first of all, we are going to get the log in user and it's equal to cost.
User is equal to the rec dot session, dot user off and this one represents the ID.
So next step is that we are going to find the user.
So going to be as cost user is equal to a weight and then the user model filed by ID and the ID is the
log in user.
So let's make use of user ID and pass in the user ID here.
So next is I'm going to send the response.
So here provide data and then the user.
So that is it.
So let's go ahead and then make a request to the profile hit sent and you can see that we have the response
back.
But I want to avoid the ID, so let's remove the ID here and let's get back to the user route and remove
the params.
So users and let's locate the profile, which is this.
So like I said, I don't want to pass the id into the param, so let's move that one.
So now everything remains the same.
If I make the request, let's see the response.
Well, we have user details, meaning that some root has been caught.
The problem is that this route caught before even getting here because express routing always look at
the first mountain route.
So always try to bring route with some ID below other route.
So let me paste it here.
So this one is going to match this one exactly.
So let's hit send and we have the response coming back and we can see we have the post and then the
comment for the meantime, there is no post that has been created by this user likewise comment.
So as you move on, we will come back and finish up the user profile.
All right.
So let's get continue in the next video.