From the course: Next.js: Creating and Hosting a Full-Stack Site
Unlock this course with a free trial
Join today to access over 24,500 courses taught by industry experts.
Solution: Removing items from the cart - React.js Tutorial
From the course: Next.js: Creating and Hosting a Full-Stack Site
Solution: Removing items from the cart
(upbeat music) - [Instructor] Okay, well hopefully at this point you've given the challenge a try. So let's walk through the solution. And the solution that I'm going to show you is just one way of doing things, so if you are able to figure out how to get the functionality to work in a different way, that's fine too. So let's start off here by adding the functionality to the products page. And in order to do that, we need to implement the Remove From Cart functionality, right? Right now we just print something out to the console when we click on the Remove From Cart button. So we're going to need to actually add a function here that makes a request to the route handler for removing items from the cart. Cool, so in order to do this, what I did is I just copied the addToCart function, and I used that as a template, and I changed this to removeFromCart, changed the name, anyway. And just like with the addToCart function, I used the product ID as the argument there to make things a little…
Contents
-
-
-
-
-
-
(Locked)
Data loading basics in Next.js1m 13s
-
(Locked)
Loading data with Fetch5m 57s
-
(Locked)
Loading all products3m 39s
-
(Locked)
Loading individual products3m 9s
-
(Locked)
Loading shopping cart items6m 16s
-
(Locked)
Adding items to the cart10m 5s
-
(Locked)
Shopping cart improvements6m 2s
-
(Locked)
Challenge: Removing items from the cart1m 28s
-
(Locked)
Solution: Removing items from the cart5m 34s
-
(Locked)
-
-