1
00:00:00,400 --> 00:00:07,290
All right, so at this point, we're familiar with two ways how we can send a post request.

2
00:00:07,960 --> 00:00:16,030
So we covered how we can do that using the form as well as straight up HTP request in our case, using

3
00:00:16,030 --> 00:00:20,910
JavaScript, how there's a major problem in our current setup.

4
00:00:21,340 --> 00:00:23,260
And the problem here is following.

5
00:00:24,240 --> 00:00:32,400
If we need to create a front and to test something for every route, as you can see, I mean, our development

6
00:00:32,400 --> 00:00:39,180
is going to be extremely slow because we can clearly see that it's probably going to take us way longer

7
00:00:39,180 --> 00:00:44,580
just to set up a front and then setting up just one simple route.

8
00:00:44,850 --> 00:00:49,860
So every time I create a route, I'm probably going to spend, I don't know, five or six times more

9
00:00:50,640 --> 00:00:54,050
on setting up the front end where I can test this route.

10
00:00:54,540 --> 00:00:56,940
And of course, there has to be a better option.

11
00:00:56,940 --> 00:01:00,900
And that better option is a tool called postmen.

12
00:01:01,380 --> 00:01:06,650
And Postman is just awesome for quickly testing our APIs.

13
00:01:06,990 --> 00:01:12,830
So at this point, I strongly suggest that you navigate to postman dot com again.

14
00:01:12,840 --> 00:01:15,570
It's a free tool, so you're not going to have to pay anything.

15
00:01:15,780 --> 00:01:18,930
But for a matter of the course, yes, we'll use this.

16
00:01:19,180 --> 00:01:25,280
So if you're kind of iffy about installing something new, this is something that is required.

17
00:01:25,620 --> 00:01:31,580
So navigate to postman dot com and then they'll try to sign you up.

18
00:01:31,590 --> 00:01:32,730
You don't have to do that.

19
00:01:32,970 --> 00:01:39,690
Just keeps growing down, keeps going down and all the way to the bottom you'll see this download option

20
00:01:39,900 --> 00:01:43,920
go here and they'll right away detect which operating system errors.

21
00:01:43,920 --> 00:01:48,120
And of course, in my case that is Maxo download the application.

22
00:01:48,270 --> 00:01:51,420
Once it's on my computer, I'm going to navigate back to the desktop.

23
00:01:51,420 --> 00:01:52,620
I'm going to go to download.

24
00:01:52,770 --> 00:01:54,180
I'll crack it open.

25
00:01:54,510 --> 00:02:00,420
And of course, I'll just move it to my applications like so now I already had one on my computer,

26
00:02:00,420 --> 00:02:03,900
but I removed it so we can do these steps together.

27
00:02:04,140 --> 00:02:08,729
Then this is the application, which means the woman, that's the postman.

28
00:02:08,970 --> 00:02:17,760
So just click on it and mine is going to open up the app and eventually you'll hit the dashboard.

29
00:02:18,090 --> 00:02:21,750
And I'm not going to spend half an hour on the setup.

30
00:02:21,750 --> 00:02:28,740
But of course, as we're progressing, we the course, as we're progressing with our examples, we will

31
00:02:28,740 --> 00:02:33,150
cover more features that of this app provides.

32
00:02:33,540 --> 00:02:39,900
And basically, here you have all your requests that you can actually group in collections.

33
00:02:40,200 --> 00:02:42,990
And again, that's something that will cover a bit later.

34
00:02:43,260 --> 00:02:45,810
And this is where we can make those requests.

35
00:02:46,140 --> 00:02:50,900
And in order to create in your request, we just click on this plus sign and check it out.

36
00:02:51,120 --> 00:02:59,280
So the moment I have untitled a request in here, I need to enter the URL and I can send my request.

37
00:02:59,670 --> 00:03:01,530
No notice here on the left hand side.

38
00:03:01,710 --> 00:03:02,580
What do I have?

39
00:03:02,880 --> 00:03:03,750
I have get.

40
00:03:04,050 --> 00:03:09,390
But what's really cool, I have all these methods available as well.

41
00:03:09,660 --> 00:03:15,810
So first, let's test out the ground and we'll see how we can deal with post drought as well.

42
00:03:16,140 --> 00:03:24,420
Now, as far as our URL, what it is, well, it is localhost five thousand and of course the full YORO

43
00:03:24,420 --> 00:03:29,970
is API and people, this is for the Post as well as the GET.

44
00:03:30,150 --> 00:03:36,000
And since we're testing it, of course, that's why we have a method we at the value of it.

45
00:03:36,240 --> 00:03:46,590
So let's go here a local post and the thousand then forward slash API and people and the moment I click

46
00:03:46,590 --> 00:03:48,480
send check it out.

47
00:03:48,720 --> 00:03:50,190
What do I see here in the bottom?

48
00:03:50,460 --> 00:03:55,650
I see my object of the success value is true and there I have my data.

49
00:03:55,920 --> 00:04:03,270
So as you can see, the moment I create my route, for example, post trought or put out or whatever,

50
00:04:03,540 --> 00:04:05,910
I can test it immediately.

51
00:04:06,270 --> 00:04:10,370
I can test it within a few seconds instead of building the whole front.

52
00:04:10,380 --> 00:04:13,800
And just so I can test one route.

53
00:04:14,070 --> 00:04:18,959
And of course, once we have covered Getrag, now let's see how we can deal with a post truck.

54
00:04:19,290 --> 00:04:20,790
So we need to change the method.

55
00:04:21,240 --> 00:04:28,290
Of course, now the euro still stays the same because I do have a route for the post, as you can see

56
00:04:28,590 --> 00:04:30,360
and hear what I'm looking for.

57
00:04:30,600 --> 00:04:33,570
I'm looking for the name in the body.

58
00:04:34,050 --> 00:04:37,700
And how do we construct a post request in a post?

59
00:04:38,010 --> 00:04:39,960
Well, we do that in the following way.

60
00:04:40,230 --> 00:04:49,200
First we go to the body and we look for and instead of text, I go with Jason because I'm going to be

61
00:04:49,200 --> 00:04:51,060
sending a JSON data.

62
00:04:51,480 --> 00:04:54,990
So this is not the case where we're working with the forms.

63
00:04:55,380 --> 00:04:57,900
In this case, we're sending a Jason day.

64
00:04:58,230 --> 00:05:04,290
And what you'll notice something really interesting in the headers right away, there's going to be

65
00:05:04,500 --> 00:05:05,760
a content type.

66
00:05:06,300 --> 00:05:07,020
So let's see.

67
00:05:07,230 --> 00:05:10,110
Let's set up first the body and you'll see how it gets added.

68
00:05:10,410 --> 00:05:13,650
So we're going to go here with a name again.

69
00:05:13,650 --> 00:05:14,940
This is what I'm looking for.

70
00:05:15,120 --> 00:05:16,320
That's why I need to pass it.

71
00:05:16,560 --> 00:05:21,360
And then I'm going to set up some kind of now, since I'm sending up to Jason, please remember that

72
00:05:21,360 --> 00:05:23,640
we need to use double quotation marks.

73
00:05:24,020 --> 00:05:30,230
So I'm going to go here with John, and if you paid attention previously we had eight headers and now

74
00:05:30,230 --> 00:05:30,950
we have nine.

75
00:05:31,250 --> 00:05:37,420
So I'm going to go back and there is now I have content type application, Jason.

76
00:05:37,910 --> 00:05:38,880
So that's really cool.

77
00:05:38,900 --> 00:05:39,970
We don't have to do anything.

78
00:05:40,280 --> 00:05:42,560
The header gets added for us.

79
00:05:42,740 --> 00:05:46,290
And of course, the moment I click send check it out.

80
00:05:46,400 --> 00:05:49,850
Now I have success through and person John.

81
00:05:49,850 --> 00:05:50,980
Why do I have that?

82
00:05:50,990 --> 00:05:52,760
Well, because that is my response.

83
00:05:52,940 --> 00:05:59,100
I have success through of course, whatever name I received, I just sent it back.

84
00:05:59,120 --> 00:06:02,660
So now of course, let's quickly test out our four hundred as well.

85
00:06:02,990 --> 00:06:10,370
So I'm going to navigate back and then in the body I'm just going to send a empty string or you can

86
00:06:10,370 --> 00:06:11,780
remove a name altogether.

87
00:06:11,990 --> 00:06:13,070
That's really up to you.

88
00:06:13,360 --> 00:06:20,900
And of course I have four hundred by request and the success is false and of course I can see the message.

89
00:06:21,110 --> 00:06:23,840
So as you can see we can test it within seconds.

90
00:06:24,080 --> 00:06:31,040
And to really hammer this home, why don't we create another poster out and quickly set up some kind

91
00:06:31,040 --> 00:06:35,270
of response and let's set out in our post, not as well.

92
00:06:35,570 --> 00:06:39,140
So I'm going to go in between the post and a login.

93
00:06:39,530 --> 00:06:44,840
I'm just going to go with that post and the route is going to be following.

94
00:06:44,840 --> 00:06:52,100
I'm going to go with path of API people, people, and I'm going to add a postman here.

95
00:06:53,030 --> 00:06:54,320
Or, you know, let's do it this way.

96
00:06:54,560 --> 00:07:04,670
Let's go postmen and and people like so and as far as the callback function, again, we get Rech rise

97
00:07:05,150 --> 00:07:07,880
and shine in the body again.

98
00:07:07,890 --> 00:07:12,740
I'm going to be looking for the name property, so I want to get that name.

99
00:07:13,040 --> 00:07:16,850
So I'm going to say that I'm expecting it will go with name.

100
00:07:17,000 --> 00:07:19,340
Rock that body again.

101
00:07:19,340 --> 00:07:22,030
If you want to control the body, you can do so.

102
00:07:22,040 --> 00:07:25,610
But I think we have done that quite a few times, so I'm going to admit that.

103
00:07:25,850 --> 00:07:29,500
Then I'll copy and paste my response.

104
00:07:29,720 --> 00:07:36,080
So again, if the name is not provided, meaning if the property is not there or if it's just empty,

105
00:07:36,290 --> 00:07:37,760
I'm sending back the four hundred.

106
00:07:37,760 --> 00:07:42,680
However, if I'm successful then I'm just going to take my all.

107
00:07:43,190 --> 00:07:46,240
I'll add that extra person and I'll send it back.

108
00:07:46,400 --> 00:07:51,770
Now I'm not going to add the ID, I'll leave that one blank because eventually database will do that

109
00:07:51,770 --> 00:07:52,120
for us.

110
00:07:52,130 --> 00:07:55,970
So I don't really see the point of doing that manually.

111
00:07:56,210 --> 00:07:59,540
So I'm going to go back to my API postmen people.

112
00:07:59,840 --> 00:08:05,570
And then again, this is my error response and I'll copy and paste our status.

113
00:08:05,780 --> 00:08:10,820
And then instead of sending that one person we created, why don't we do this?

114
00:08:11,000 --> 00:08:12,650
Why don't we go with data?

115
00:08:13,100 --> 00:08:15,950
And then of course, the array name is people.

116
00:08:16,070 --> 00:08:22,220
And now, as you can see, I'm using this propre and I'm just going to add that one single person,

117
00:08:22,520 --> 00:08:23,960
so I'll save.

118
00:08:24,230 --> 00:08:26,360
Now, of course, we do need to change the route.

119
00:08:26,720 --> 00:08:32,620
So it's not going to be API, it's going to be postmen and people like.

120
00:08:32,630 --> 00:08:40,669
So now let's add, for example, Peter, and the moment I click, send Verity's, I have my successor

121
00:08:40,909 --> 00:08:45,970
and as far as data all the way somewhere should be Peter as well.

122
00:08:46,370 --> 00:08:51,490
So again, we just grab that Peter and then we added to our array.

123
00:08:51,890 --> 00:08:52,970
Hopefully this makes sense.

124
00:08:52,970 --> 00:08:57,310
And now of course we can work on other HTP methods as well.

