WEBVTT

00:03.760 --> 00:05.770
Hey, did everyone they share in this video?

00:05.780 --> 00:10.480
We're going to go ahead and check out that, how we can provide a route and the methods or the verbs

00:10.480 --> 00:11.110
for them.

00:11.260 --> 00:16.900
So the first one obviously we got is add review, delete review and get only reviews for one product.

00:16.900 --> 00:21.280
So there are a couple of routes admin we have already worked on that, so shouldn't be a big deal.

00:21.280 --> 00:22.540
These are just the user routes.

00:22.540 --> 00:24.160
So let's start with the ADD review.

00:24.430 --> 00:30.070
So while working with the ADD reviews, so we are allowing to add reviews, but this can be a little

00:30.070 --> 00:35.890
bit deceiving to beginners, especially because this is not actually an ad route, but this is rather

00:35.890 --> 00:41.500
a put route because we are not creating a fresh model itself or a fresh object in the model.

00:41.500 --> 00:43.270
We are actually updating the model.

00:43.300 --> 00:44.590
That product was already created.

00:44.590 --> 00:46.150
We are just adding a review onto that.

00:46.150 --> 00:48.610
So we need to actually work similar to that.

00:48.760 --> 00:50.950
So let's go ahead and say that first.

00:50.950 --> 00:52.300
Let's go ahead and bring this one.

00:52.300 --> 00:54.340
So get ADD review.

00:54.340 --> 00:59.170
So copy that comes up there and this one is going to be ad review.

00:59.410 --> 00:59.730
Okay.

00:59.740 --> 01:01.810
So what is the route that you are going to provide me?

01:01.810 --> 01:03.940
I think just the review is good enough.

01:03.940 --> 01:06.790
So we're going to go ahead and say, because this is already very unique.

01:06.790 --> 01:11.620
So somebody says, hey, I want to add a review, so let's go ahead and just say ad review.

01:11.650 --> 01:15.670
This is obviously going to be a put request because we are not creating anything.

01:15.670 --> 01:20.470
We are just updating the existing product and this will be handled by just the ADD review.

01:20.470 --> 01:25.240
So I think this is more than enough thinking about another one, which is a delete review.

01:25.240 --> 01:27.220
So this is obviously a delete request.

01:27.220 --> 01:29.440
Shouldn't be bothered too much on that part.

01:29.590 --> 01:32.590
Let's go ahead and say, hey, this is a delete review request.

01:32.590 --> 01:33.280
There we go.

01:33.430 --> 01:35.350
Let's go ahead and add this one.

01:35.500 --> 01:39.010
So add the time of deleting the review.

01:39.010 --> 01:40.450
Let's go ahead and explode that.

01:40.480 --> 01:45.100
Remember, we are requesting everything from the query, so I don't need to grab anything from the URL

01:45.100 --> 01:47.830
in case the way how you talk to the front end guy.

01:47.860 --> 01:50.170
He says No, I want to send it into the URL.

01:50.200 --> 01:54.880
Then obviously we have to provide it out like something like a review slash colon ID or something like

01:54.880 --> 01:55.270
that.

01:55.270 --> 01:57.880
But we are expecting everything to come up from there.

01:58.150 --> 01:58.400
Okay.

01:58.480 --> 02:00.580
So this is request dot query product.

02:00.580 --> 02:04.930
It is coming from there and from the product ID, request dot user ID.

02:04.930 --> 02:06.370
So everything is fine here.

02:06.670 --> 02:06.970
Okay.

02:06.970 --> 02:07.510
Moving on.

02:07.510 --> 02:11.680
So this one is going to be simply a delete method.

02:11.680 --> 02:19.000
So delete and the array is or the method is going to be delete and this one is going to be review.

02:19.000 --> 02:22.450
So I think a put request on the review and a delete request on the review.

02:22.450 --> 02:23.380
So that's fine.

02:23.440 --> 02:30.340
Moving on after the delete one, we are having a get only reviews for one product, so that is also

02:30.340 --> 02:31.510
needs to be implemented.

02:31.990 --> 02:38.590
So let's go ahead and have the root copy this one, add another one.

02:38.590 --> 02:40.450
So obviously this is a get request.

02:40.450 --> 02:41.890
So nobody is giving me anything.

02:41.890 --> 02:46.660
So I'm going to go ahead and say, hey, this is a get let's go ahead and say that this is all reviews

02:46.660 --> 02:49.270
or we can call this slash product reviews.

02:49.270 --> 02:51.190
How would like to go ahead and work on with that?

02:51.460 --> 02:53.860
This is going to be worked on just like that.

02:53.860 --> 02:59.860
So anybody who is going with that now, we are also going to implement that.

03:00.220 --> 03:05.470
It's up to you that whether you want the reviews to be seen by only the guys who are logged in or not,

03:05.470 --> 03:07.210
I would definitely like to have that.

03:07.210 --> 03:12.100
This get input request should be added only by the guys who are logged in, not the admin, just the

03:12.100 --> 03:12.700
logged in.

03:12.880 --> 03:17.380
So because somebody is changing some things in the database, so this is really something we should

03:17.380 --> 03:17.920
protect.

03:17.920 --> 03:18.640
There we go.

03:18.880 --> 03:28.180
So the review both put and delete requests, basically the add, basically add and edit as well as the

03:28.180 --> 03:28.540
delete.

03:28.540 --> 03:30.430
So three requests are being protected there.

03:30.760 --> 03:33.520
Now, this one, it's up to you.

03:33.520 --> 03:34.870
I'm going to leave this one to you.

03:34.870 --> 03:38.950
I'll just protect this in case you don't want to protect this, just remove this logged in.

03:39.400 --> 03:44.620
It's up to you whether you want to show reviews to the logged in user or non non logged in user.

03:44.650 --> 03:45.250
Up to you.

03:45.280 --> 03:45.880
Up to you.

03:46.150 --> 03:48.460
I'll just say that hey I'll protect the reviews as well.

03:48.460 --> 03:50.050
Only logged in user can see that.

03:50.050 --> 03:54.700
But again we are having just fun here in case you don't want to do that, you just have to remove this

03:54.700 --> 03:54.970
thing.

03:54.970 --> 04:00.430
So I hope you understand and again, since we are getting a pro into the back end only remember we can

04:00.430 --> 04:06.370
always come back here and just update that one simple, tiny thing and I'll leave this decision up to

04:06.370 --> 04:08.140
you how you want to go ahead and do that.

04:08.140 --> 04:10.000
Let's go ahead and catch up in the next one.
