1
00:00:00,180 --> 00:00:09,150
In this video, let's implement the logic for fetching the profile of a user so inside the controller,

2
00:00:09,150 --> 00:00:10,660
and that's for the user.

3
00:00:10,680 --> 00:00:13,260
Let's go ahead and then make the logic.

4
00:00:13,350 --> 00:00:15,310
Let's collapse the log in.

5
00:00:15,330 --> 00:00:16,260
We are done with that.

6
00:00:16,260 --> 00:00:19,590
And this is the profile for the profile.

7
00:00:19,590 --> 00:00:28,170
You can see that we are passing the ID of the login user into the user as a and I don't want that.

8
00:00:28,170 --> 00:00:36,030
So we have the looking user and the rec session and that is the ID, so we can use that one to make

9
00:00:36,030 --> 00:00:39,600
a request, our database to find the log in user.

10
00:00:39,600 --> 00:00:41,010
So here we go.

11
00:00:41,010 --> 00:00:48,690
So first of all, we are going to get the log in user and it's equal to cost.

12
00:00:48,720 --> 00:00:57,630
User is equal to the rec dot session, dot user off and this one represents the ID.

13
00:00:57,780 --> 00:01:02,250
So next step is that we are going to find the user.

14
00:01:02,250 --> 00:01:13,920
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

15
00:01:13,920 --> 00:01:14,790
log in user.

16
00:01:14,790 --> 00:01:20,700
So let's make use of user ID and pass in the user ID here.

17
00:01:21,120 --> 00:01:24,330
So next is I'm going to send the response.

18
00:01:24,330 --> 00:01:28,380
So here provide data and then the user.

19
00:01:28,500 --> 00:01:30,030
So that is it.

20
00:01:30,030 --> 00:01:38,460
So let's go ahead and then make a request to the profile hit sent and you can see that we have the response

21
00:01:38,460 --> 00:01:39,090
back.

22
00:01:39,090 --> 00:01:47,910
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

23
00:01:47,910 --> 00:01:48,870
the params.

24
00:01:48,870 --> 00:01:54,030
So users and let's locate the profile, which is this.

25
00:01:54,030 --> 00:01:59,400
So like I said, I don't want to pass the id into the param, so let's move that one.

26
00:01:59,400 --> 00:02:01,920
So now everything remains the same.

27
00:02:02,100 --> 00:02:05,460
If I make the request, let's see the response.

28
00:02:05,460 --> 00:02:11,250
Well, we have user details, meaning that some root has been caught.

29
00:02:11,340 --> 00:02:18,780
The problem is that this route caught before even getting here because express routing always look at

30
00:02:18,780 --> 00:02:20,610
the first mountain route.

31
00:02:20,610 --> 00:02:26,430
So always try to bring route with some ID below other route.

32
00:02:26,440 --> 00:02:28,260
So let me paste it here.

33
00:02:28,800 --> 00:02:32,700
So this one is going to match this one exactly.

34
00:02:32,700 --> 00:02:41,220
So let's hit send and we have the response coming back and we can see we have the post and then the

35
00:02:41,220 --> 00:02:48,300
comment for the meantime, there is no post that has been created by this user likewise comment.

36
00:02:48,300 --> 00:02:54,090
So as you move on, we will come back and finish up the user profile.

37
00:02:54,360 --> 00:02:54,750
All right.

38
00:02:54,750 --> 00:02:57,300
So let's get continue in the next video.

