1
00:00:01,220 --> 00:00:02,360
In this video.

2
00:00:02,360 --> 00:00:07,110
Let's make the actual request to be able to create a post.

3
00:00:07,130 --> 00:00:12,170
The hard work is done and that is the controller or the API.

4
00:00:12,200 --> 00:00:17,870
So let's get to the post form and inside views and post.

5
00:00:17,870 --> 00:00:19,190
And here we go.

6
00:00:19,190 --> 00:00:23,810
What has left for the form is about the endpoint.

7
00:00:23,810 --> 00:00:30,500
So here is going to be forward slash API value one and the post.

8
00:00:30,530 --> 00:00:33,920
This is the endpoint for creation of the post.

9
00:00:33,950 --> 00:00:42,530
If you go to the post route, let's cross check the endpoint and this is the endpoint for creation and

10
00:00:42,530 --> 00:00:43,820
this is the endpoint.

11
00:00:43,820 --> 00:00:52,190
So let's go ahead and then provide the end type because we are creating a post with an image, meaning

12
00:00:52,190 --> 00:00:59,210
that we are not sending the JSON data, but instead we are sending what is called form data.

13
00:00:59,300 --> 00:01:03,260
So let's go ahead and then provide the end type.

14
00:01:04,750 --> 00:01:10,900
And I'm going to be multipart slash form data and going to be post method.

15
00:01:10,900 --> 00:01:15,960
So let's check let's refresh it for the title.

16
00:01:15,970 --> 00:01:18,190
I'll make use of how to.

17
00:01:19,790 --> 00:01:28,340
Become a developer or dev category, you're going to be Node.js and Abadi I'm going to use this dummy

18
00:01:28,340 --> 00:01:30,890
text here and.

19
00:01:31,510 --> 00:01:32,290
I saw that.

20
00:01:32,290 --> 00:01:34,000
And then the image.

21
00:01:34,000 --> 00:01:36,490
I want to use this image.

22
00:01:39,880 --> 00:01:41,110
And great.

23
00:01:41,900 --> 00:01:49,490
And you can see that we have motor error simply means that we are using what is called image.

24
00:01:49,490 --> 00:01:53,630
But inside the mortar we use what is called file.

25
00:01:53,660 --> 00:01:57,230
Let me show you inside the post route for the mortar.

26
00:01:57,260 --> 00:02:04,160
We use file as a field name, so let's use the same as that as file.

27
00:02:04,340 --> 00:02:06,560
Now, moment of truth.

28
00:02:06,830 --> 00:02:13,130
Let me make the request again where I need to refresh it because I have made changes to it.

29
00:02:13,880 --> 00:02:16,790
So here are going to be how to become.

30
00:02:17,920 --> 00:02:18,670
At Dave.

31
00:02:21,090 --> 00:02:26,850
The category, our use, not just the body and then the image.

32
00:02:30,210 --> 00:02:36,730
And you can see that it has been created successfully because I have what is called success.

33
00:02:36,750 --> 00:02:46,320
So if I go to homepage, I'm going to see the post and you can see this is a post, but unlucky for

34
00:02:46,320 --> 00:02:53,280
us, we are not seeing the image of the post, so let's have a look where we are going wrong.

35
00:02:53,550 --> 00:02:59,570
So let's locate the model for the post and let's look at the field.

36
00:02:59,580 --> 00:03:05,340
So post and indeed is image image.

37
00:03:05,520 --> 00:03:08,100
So let's go to the template.

38
00:03:10,130 --> 00:03:12,980
And for the image.

39
00:03:14,140 --> 00:03:16,480
So it's supposed to be equal to.

40
00:03:16,510 --> 00:03:17,180
Yeah.

41
00:03:17,200 --> 00:03:19,780
But on my side, I believe you guys saw it.

42
00:03:19,780 --> 00:03:21,340
So let's refresh it.

43
00:03:22,490 --> 00:03:27,680
And these are the images and post we have.

44
00:03:27,710 --> 00:03:28,700
All right.

45
00:03:28,700 --> 00:03:30,350
You can see that we have it.

46
00:03:30,680 --> 00:03:38,880
But on lucky for us, we are not seeing the user, even though we are populating inside the controller.

47
00:03:38,900 --> 00:03:43,030
So let's go to post and that is fetching or post.

48
00:03:43,040 --> 00:03:46,550
You can see that we are using the populate here.

49
00:03:46,580 --> 00:03:48,560
So why are we not having it?

50
00:03:48,590 --> 00:03:57,320
Well, I remember guys, we are not using this one for the home page, but instead we are using this

51
00:03:57,320 --> 00:04:00,750
route inside the server, which is this.

52
00:04:00,770 --> 00:04:05,180
So for this one we can go ahead and then populate the user.

53
00:04:07,520 --> 00:04:11,240
All right, So save it and let's refresh it.

54
00:04:13,480 --> 00:04:20,110
And you can see that we have the user and then the date this post was created.

55
00:04:20,170 --> 00:04:27,880
So if I go to the profile page, I'm going to see the new post that I created, which is this.

56
00:04:27,940 --> 00:04:32,170
But for this one, I'm not seeing the description of the post.

57
00:04:32,170 --> 00:04:37,510
So let's get back to the profile page and let's fix that.

58
00:04:37,600 --> 00:04:40,150
So let's go to the views.

59
00:04:40,970 --> 00:04:43,910
Users and profile.

60
00:04:44,120 --> 00:04:47,870
So let's look through this.

61
00:04:47,870 --> 00:04:50,480
One is an image of the post.

62
00:04:51,390 --> 00:04:54,150
The date the post was created.

63
00:04:55,230 --> 00:05:05,400
And then the description is supposed to be equal to three guys, equal to and equal to.

64
00:05:05,430 --> 00:05:08,880
Likewise there and likewise that.

65
00:05:09,000 --> 00:05:10,740
But on my side.

66
00:05:11,070 --> 00:05:12,570
I apologize for that.

67
00:05:12,780 --> 00:05:15,420
Let's refresh it and let's have a look.

68
00:05:15,420 --> 00:05:18,000
And we have it as that.

69
00:05:18,000 --> 00:05:24,030
And for the dates, let's try to reformat it by using to look up.

70
00:05:24,060 --> 00:05:31,200
So it's going to be as this so I'm going to copy this one and use it on this date.

71
00:05:32,290 --> 00:05:33,030
As that.

72
00:05:33,030 --> 00:05:35,070
So let's refresh it.

73
00:05:35,830 --> 00:05:37,500
And it worked fine.

74
00:05:37,510 --> 00:05:45,310
But you can see that some images are bigger than the other and we can fix this one using CSS.

75
00:05:45,340 --> 00:05:50,070
And then you can also see that there are some content which are more.

76
00:05:50,080 --> 00:05:57,040
So what you are going to do is that we are going to create a function to truncate to, let's say, 100

77
00:05:57,040 --> 00:05:57,910
characters.

78
00:05:57,910 --> 00:06:02,890
So let's go ahead and then display error in case we have one in the next video.

