WEBVTT

00:03.820 --> 00:04.720
Hey there, everyone.

00:04.780 --> 00:09.670
This year it's almost 2:00 in the night, so we're going to handle just one more case tonight and the

00:09.670 --> 00:11.320
rest of the videos we'll do tomorrow.

00:11.440 --> 00:16.240
So what we're going to do in this one, in this one, we'll learn that how we can handle a raise, not

00:16.240 --> 00:20.440
just the ordinary areas, areas which are a little bit complex and you'll be seeing this kind of area

00:20.470 --> 00:21.280
more often.

00:21.280 --> 00:25.750
So in this case, we have already defined the arrays with just doesn't hold the string but actually

00:25.750 --> 00:29.860
holds a complex object, which is in itself an object.

00:29.860 --> 00:35.020
So how we're going to do that first, we're going to define a new route for it and we're going to throw

00:35.020 --> 00:36.550
back this array as it is.

00:36.550 --> 00:38.800
So we're going to just make a copy of this one.

00:38.800 --> 00:44.380
Let's get some space and here let's go ahead and call this out as probably causes.

00:44.380 --> 00:45.400
So there we go.

00:46.000 --> 00:49.030
OC code says, there we go.

00:49.240 --> 00:49.540
Okay.

00:49.540 --> 00:52.300
In the course we won't be handling anything complex.

00:52.600 --> 00:56.230
We don't have knowledge anyways to handle much of the complex as of now.

00:56.410 --> 01:01.240
Yes, we will design the complex APIs and infrastructure of that, but not right now.

01:01.240 --> 01:04.180
Right now the only goal is to understand the documentation.

01:04.360 --> 01:06.100
So now my route is all clear.

01:06.100 --> 01:11.230
Now I can go into the swagger and obviously I need to create another route so I will copy.

01:11.230 --> 01:12.490
As you know, I love this one.

01:12.490 --> 01:14.650
This saves me a whole lot of time.

01:15.100 --> 01:17.410
This is how this is going to be.

01:17.410 --> 01:18.940
Let's go ahead and hit an enter.

01:18.940 --> 01:19.690
There we go.

01:19.690 --> 01:22.630
Now I will have a route which will be courses.

01:22.960 --> 01:25.540
This will be in itself an array.

01:25.570 --> 01:30.700
Again, you can name as many tags or if you can use reuse some of the tags previously mentioned, it

01:30.700 --> 01:31.900
will grow them together.

01:32.200 --> 01:39.970
The summary It doesn't return a unique course, but it returns all courses, courses like that.

01:40.090 --> 01:43.210
Now we will be working on just one response which is 200.

01:43.210 --> 01:45.190
So description, all good success.

01:45.190 --> 01:50.290
The content type is of application JSON because although we haven't sent any of the JSON here, we are

01:50.290 --> 01:54.970
just using resource and I don't want to use the another middleware and stuff.

01:54.970 --> 01:56.980
So you get the idea how it is being done.

01:57.130 --> 02:01.660
Now, the schema this time it is not a type object but rather a type of array.

02:01.690 --> 02:07.210
Remember I told you in the previous video that although you can say that in the array, also further

02:07.210 --> 02:11.080
properties are there, it can be a string or a couple of numbers.

02:11.080 --> 02:15.340
Yes, technically they are also called as properties, but usually in the documentation.

02:15.340 --> 02:19.420
As soon as the object comes in, then only the properties can be used.

02:19.420 --> 02:25.210
So in the case of array, obviously the rather the perfect word for calling anything that is inside

02:25.210 --> 02:27.790
the array are items and that's what exactly being used.

02:27.790 --> 02:32.200
I'm telling you this because it's not compulsory to remember, but these talks actually help you to

02:32.200 --> 02:33.940
remember things for a longer run.

02:34.060 --> 02:40.780
So in here we are going to say that inside this array we do have items and once you have these items,

02:40.780 --> 02:43.990
then you have to define that what each item looks like.

02:43.990 --> 02:47.050
So in my case, the item I have to mention the type.

02:47.050 --> 02:52.240
Now here I can go ahead and say that, hey, this array is returning all the strings or numbers or something

02:52.240 --> 02:52.900
like that.

02:52.900 --> 02:56.110
But in this case, I'll just move on to the same line.

02:56.560 --> 02:56.970
Yeah.

02:57.550 --> 02:59.650
What I'm coming back is the object.

02:59.650 --> 03:04.840
Now, once you have defined that, okay, the type is object, then I can introduce my properties to

03:04.840 --> 03:06.760
further define that how this is looking like.

03:06.760 --> 03:09.100
But this is not a correct way of indentation.

03:09.100 --> 03:14.500
So I'll just select and I'll use control and the square arrow square brackets.

03:14.500 --> 03:19.930
So control and square bracket and this will indent it properly, make sure you keep an eye on the indentation,

03:19.930 --> 03:21.400
otherwise it will hurt you badly.

03:21.400 --> 03:24.970
And debugging is a little bit painful in this documentation.

03:25.090 --> 03:31.390
Let's save that and see that if we are doing any good here to reload and of course the root is now here

03:31.390 --> 03:32.350
it is a get root.

03:32.350 --> 03:37.840
Of course we have courses, returns, all that and we see it's all good success, application, JSON,

03:37.840 --> 03:40.120
nice and easy and we are having a schema.

03:40.120 --> 03:45.850
So notice it says array and then we have the object inside this one which is exactly same as we define.

03:45.850 --> 03:49.630
And we can also check out the schema that this is how the schema looks like.

03:49.630 --> 03:53.530
We have an array a little bit difficult to see from here.

03:53.530 --> 03:56.800
This is like little bit hidden, but I'll try to zoom it a little bit.

03:56.830 --> 04:02.110
We get the same schema that we have defined and we can just go ahead and try out execute and it turns

04:02.110 --> 04:04.540
me entirety 30 of the array that we have seen.

04:04.540 --> 04:05.650
So this is good.

04:05.650 --> 04:08.650
And again, it doesn't really matter.

04:08.650 --> 04:12.910
Even if I write don't write properties or I say items that are going to get is a string.

04:12.940 --> 04:17.380
Yes, I can technically write that, but when the request is being made to the server, the response

04:17.380 --> 04:19.150
we are getting, it can be different.

04:19.540 --> 04:23.020
It shouldn't be different, but it can be different in the majority of the cases.

04:23.020 --> 04:27.370
In fact, in all the cases you want them to be as closely as what result we are going to get.

04:27.760 --> 04:32.890
There is no explicit check being mentioned that the documentation are properly mentioned or correct

04:32.890 --> 04:33.430
or not.

04:33.550 --> 04:36.460
Okay, so now you know that a couple of things you can handle.

04:36.460 --> 04:39.670
You can handle strings, you can handle objects and array as well.

04:39.700 --> 04:44.140
Definitely there is a lot more to understand, a whole lot of post requests and a whole bunch of other

04:44.140 --> 04:46.060
things that I'm going to do tomorrow.

04:46.060 --> 04:48.580
But you can just click on the next video and watch it next up.

04:48.580 --> 04:50.650
So let's go ahead and catch up in the next video.
