Hey, did everyone they share in this video?
We're going to go ahead and check out that, how we can provide a route and the methods or the verbs
for them.
So the first one obviously we got is add review, delete review and get only reviews for one product.
So there are a couple of routes admin we have already worked on that, so shouldn't be a big deal.
These are just the user routes.
So let's start with the ADD review.
So while working with the ADD reviews, so we are allowing to add reviews, but this can be a little
bit deceiving to beginners, especially because this is not actually an ad route, but this is rather
a put route because we are not creating a fresh model itself or a fresh object in the model.
We are actually updating the model.
That product was already created.
We are just adding a review onto that.
So we need to actually work similar to that.
So let's go ahead and say that first.
Let's go ahead and bring this one.
So get ADD review.
So copy that comes up there and this one is going to be ad review.
Okay.
So what is the route that you are going to provide me?
I think just the review is good enough.
So we're going to go ahead and say, because this is already very unique.
So somebody says, hey, I want to add a review, so let's go ahead and just say ad review.
This is obviously going to be a put request because we are not creating anything.
We are just updating the existing product and this will be handled by just the ADD review.
So I think this is more than enough thinking about another one, which is a delete review.
So this is obviously a delete request.
Shouldn't be bothered too much on that part.
Let's go ahead and say, hey, this is a delete review request.
There we go.
Let's go ahead and add this one.
So add the time of deleting the review.
Let's go ahead and explode that.
Remember, we are requesting everything from the query, so I don't need to grab anything from the URL
in case the way how you talk to the front end guy.
He says No, I want to send it into the URL.
Then obviously we have to provide it out like something like a review slash colon ID or something like
that.
But we are expecting everything to come up from there.
Okay.
So this is request dot query product.
It is coming from there and from the product ID, request dot user ID.
So everything is fine here.
Okay.
Moving on.
So this one is going to be simply a delete method.
So delete and the array is or the method is going to be delete and this one is going to be review.
So I think a put request on the review and a delete request on the review.
So that's fine.
Moving on after the delete one, we are having a get only reviews for one product, so that is also
needs to be implemented.
So let's go ahead and have the root copy this one, add another one.
So obviously this is a get request.
So nobody is giving me anything.
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
or we can call this slash product reviews.
How would like to go ahead and work on with that?
This is going to be worked on just like that.
So anybody who is going with that now, we are also going to implement that.
It's up to you that whether you want the reviews to be seen by only the guys who are logged in or not,
I would definitely like to have that.
This get input request should be added only by the guys who are logged in, not the admin, just the
logged in.
So because somebody is changing some things in the database, so this is really something we should
protect.
There we go.
So the review both put and delete requests, basically the add, basically add and edit as well as the
delete.
So three requests are being protected there.
Now, this one, it's up to you.
I'm going to leave this one to you.
I'll just protect this in case you don't want to protect this, just remove this logged in.
It's up to you whether you want to show reviews to the logged in user or non non logged in user.
Up to you.
I'll just say that hey I'll protect the reviews as well.
Only logged in user can see that.
But again we are having just fun here in case you don't want to do that, you just have to remove this
thing.
So I hope you understand and again, since we are getting a pro into the back end only remember we can
always come back here and just update that one simple, tiny thing and I'll leave this decision up to
you how you want to go ahead and do that.
Let's go ahead and catch up in the next one.