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

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