1
00:00:00,390 --> 00:00:05,950
In this video, we are going to create a controller to fetch a single post.

2
00:00:05,970 --> 00:00:10,860
So let's get back to the controllers and post and then post controller.

3
00:00:10,890 --> 00:00:12,570
Let's collapse this one.

4
00:00:12,570 --> 00:00:20,760
And this is the end point for finding a single post, which is this post details or fetch posts and

5
00:00:20,760 --> 00:00:23,730
we can have the idea of the post in the params.

6
00:00:23,730 --> 00:00:38,310
So first step is that get the id from params and going to be as const id is equal to rec dot params.

7
00:00:40,280 --> 00:00:45,110
Deutsch ID and let's go ahead and find the pores in our DB.

8
00:00:45,140 --> 00:00:50,150
So find the post I'm going to be as concerned.

9
00:00:50,150 --> 00:00:59,930
Post is equal to weight post model dot find by ID and the ID is from the PARAM, which is this.

10
00:00:59,930 --> 00:01:04,819
And lastly, let's send the response back to the user as post.

11
00:01:04,819 --> 00:01:11,030
And the variable here is going to be data and let's throw an error in case we have one.

12
00:01:11,030 --> 00:01:13,220
So I'll pass in next here.

13
00:01:13,340 --> 00:01:20,750
And then inside the cache block, I'm going to call next and pass in the app error and the message can

14
00:01:20,750 --> 00:01:25,550
be found on error message and that is it.

15
00:01:25,550 --> 00:01:31,070
So let's get back to the request handler here, and that is for the 10th client.

16
00:01:31,190 --> 00:01:36,260
And let me click on details and let's find the ID of the post.

17
00:01:36,260 --> 00:01:38,150
So let's get back to our DB.

18
00:01:38,180 --> 00:01:46,580
Let me connect and inside the full stack block database post and we have three posts for me, so let

19
00:01:46,580 --> 00:01:55,790
me choose the ID of this one and here I'll provide the ID as that and let me make the request.

20
00:01:56,000 --> 00:02:00,470
And we have the single post and that is it.

21
00:02:00,470 --> 00:02:01,550
The next video.

22
00:02:01,550 --> 00:02:03,140
Let's fetch our post.

