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,800 courses taught by industry experts.
Challenge: Creating a remove-from-cart endpoint - React.js Tutorial
From the course: Next.js: Creating and Hosting a Full-Stack Site
Challenge: Creating a remove-from-cart endpoint
(upbeat music) - [Instructor] All right, so now that we've seen how to add an add-to-cart endpoint to our Next.js application, it's time for you to do a challenge. And that challenge is: You're going to add a remove-from-cart endpoint that will allow users to remove items by their ID from the shopping cart. So that is your challenge. And just a few hints here to get you started. The first thing is that, just like we've used different request methods, such as get and post, for loading and adding an item to a cart respectively, for removing an item from the cart, the general way of doing that is using a delete request. So you can probably guess what that function is going to be called, but I'll leave that up to you. And other than that, it's going to follow a pretty similar flow to how we implemented our add-to-cart endpoint, except the logic is going to be, of course, a little bit different because instead of adding an item to the cart, right, or adding an item to a list, you're going…
Contents
-
-
-
-
What are Next.js route handlers?2m 12s
-
How do Next.js route handlers work?7m 29s
-
(Locked)
Testing route handlers with Postman7m 33s
-
(Locked)
Creating a list endpoint for products5m 42s
-
(Locked)
Using route parameters in route handlers8m 10s
-
(Locked)
Creating a shopping cart endpoint9m 5s
-
(Locked)
Creating an add-to-cart endpoint9m 7s
-
(Locked)
Challenge: Creating a remove-from-cart endpoint1m 23s
-
(Locked)
Solution: Creating a remove-from-cart endpoint5m 53s
-
-
-
-
-