Hey there, everyone that they share.
And let's see how many mistakes we have made.
So it's time to test our route using the postman.
So we're going to test first that if we are able to get a single product or not, let's go into the
postman and see this.
So this is the route for getting all the products.
If I go ahead and send it, it's still working.
That is always a great thing to check out.
Let's go ahead and save this one.
And this one is going to be get one product.
So get one product.
Save this one.
Okay.
So this needs to be slash product and I should be able to access one ID and if I go ahead and send this
one into the route and I send this one, this actually gets me a one product.
Are we getting just one product?
Yep, we are getting one product.
Let's verify that.
Yep, this is one product.
So this is good.
So one testing is good.
At least we are getting one product.
Now the next route is we have already tested out the admin add testing it again doesn't really going
to harm so go ahead and test it out on your own.
Now this one is admin slash products so admin can get all the products.
Let's go ahead and test this one out already.
This doesn't need to be get all the product so this one is slash products and let's go ahead and make
a copy of this one.
So this one is actually admin, get all get admin all products.
There we go.
Save that.
And this one is if we go ahead and say the route is slash admin slash product.
So he should be able to get all the products.
So slash admin slash products, let's go ahead and send this.
So this is also same we are receiving all the products at so that we go one, two, so we have two.
So this is also working fine.
Now what else we got.
The next up is admin is getting all the product.
Now admin is able to update the product slash admin slash product slash ID.
That's interesting.
Let's go ahead and make a copy of this one.
So admin update, update one product product.
There we go.
Save this one.
And this one obviously is going to be a put request.
So save that first.
And now I want to update the product, which is a classic, right?
Code t shirt.
Copy that.
And this one is going to be slash admin, slash product, slash the ID.
And again, you can send as much data to be updated as much as you want.
But the way how we have written it is we are not checking individually that what you are sending me
or not.
We are updating it entirely based on we are only checking and doing the things optionally for the files
itself.
So if the request file exists, then we are going to check all of that.
Otherwise we'll be updating whatever all you are going to send me inside the body itself.
So make sure you are cautiously sending me all the data that you got up here.
So let's go ahead and see when we are actually adding the products to admin add product.
We should be rather copying this one.
So I'm going to go ahead and remove this one.
So this should be deleted because I want to grab all of this data here as well.
So I'm going to go ahead and say this is my admin all route and I'm going to go ahead.
And this can be saved and let's remove this, remove this and remove this.
So I am interested in admin add product.
Let's go ahead and make a copy of this one, save this one admin, update a product, save that.
And this time this is going to be a put request.
And I really hate that, that it didn't bring any of the parameters inside the body.
Know it bring that it bring that.
My bad.
So we won't be sending the photos, we won't be sending the brand and we'll be just updating the pricing.
So let's go ahead and change this one instead of 599, probably things are getting expensive.
So 699 is the stuff.
So we are just updating the price.
So now another option in front of us or another problem in front of us is send that ID properly.
So here we are receiving all the response in admin, get all products and let's also get all products
like this and let's go ahead and copy this classic write code t shirt.
ID come up here and we'll say admin slash product slash ID and we are sending all of this information
except the photo.
I don't want to check the photo as of now.
Let's see if the pricing gets to 699, send that and it says, hey, there is an error which says parameter
filter code to find must be an object.
Okay.
So this looks like that.
Sometimes the copying and pasting actually creates a problem.
So let me send that again.
And this is creating an issue.
Okay.
So find it out.
And again, it was really simple.
Here we are actually while updating one product we actually just wrote Find.
It should rather be fine by it because we are finding a product by an ID so we can go ahead and say
fine by ID.
And I guess same thing needs to be updated into the delete file as well.
So let's go ahead and work on with that part also.
So really classic bug.
And again, you can only find these bugs by having a test of that.
So hopefully this is all being saved and this looks all good.
Let's go ahead and try it one more time.
So this time let's go ahead and try the update route one more time.
We are updating the price.
Let's go ahead and send this one and it says assignment to a constant variable and looks like we are
not able to update that.
Let's go ahead and see that again one more time.
So this one was pretty classic because we are actually sending and updating this entire T of the product.
So shouldn't be a big deal.
Now let's go ahead and move on to this one where we are admin updates.
This shouldn't be a const, this should be a lit.
Again, really a very basic error.
But again, we need to test out all these things.
You need to see all these errors.
Let's go ahead and send this one more time and voila.
Finally, we have updated this after a couple of bugs.
Okay, so this is updated, but I would love to check it one more time up here.
So let's go ahead and refresh this.
And we have the t shirt of 699.
That's fine.
Now I want to delete this t shirt, which is the pro coder.
Don't want to, but I have to.
So there we go.
Let's go up here and let's make a copy of this one because this seems to be fine.
And admin delete.
Is it spelled delete like that.
Nope.
Delete looks same.
Okay.
So let's go ahead and delete the one.
This is going to be a simple delete request.
So delete.
Okay.
We don't need to send anything inside the body or anything.
All we got to do is let's go ahead and remove all of this because we don't need to send anything inside
the body we shouldn't be sending.
Let's delete this and sending the product.
We are just removing the same t shirt, which is the previous one.
It's a classic write code is getting deleted.
Let's go ahead and send this one and it says, hey, product was deleted.
That's fantastic.
And there we go.
Okay, so this is all good.
Now we have just one product in the database, so I would love to add another product.
Let's go ahead and do that just right now so that we don't have to bother too much.
So admin add product.
So admin is going to add the product.
We are going to go ahead and change this one.
So it is a classic.
I write code t shirt.
Let's go ahead and see what is the name of it.
Yeah.
Classic.
I write code 599.
All good.
Let's select the files for it.
So this one is coder and coder t.
Let's go ahead and select all of that, open that so that we have these t shirts.
And again this time we are going to change the price to 799.
Again, pricing is getting increased every day.
Okay.
So let's go ahead and send this one and see if the previous routes are working.
Nice testing for that and we'll have some data to work on with.
That's the most important thing I want to have.
Okay.
Come on.
A little bit faster than that.
Okay.
This is getting too much.
Probably we broke something.
No, we didn't broke anything.
That looks good.
Let's go ahead and check into the database if everything is working fine.
So we have two T-shirts, a classic pro coder T-shirt, as well as a classic Redcoat T-shirt.
Now, the reason for that is because obviously I want to add more fields and reviews and all of that.
We'll be doing that in the next video.