From the course: Vue.js: Creating and Hosting a Full-Stack Site

Unlock this course with a free trial

Join today to access over 25,600 courses taught by industry experts.

Adding items to the shopping cart

Adding items to the shopping cart

- [Instructor] At this point, our frontend is loading all of its data from the backend. So the next thing that we're going to take a look at is how to add items to cart by making a request to the backend. So if we take a look at the current functionality for adding an item to the cart, which you can access by going to the ProductDetailPage and taking a look at this Add to cart button, currently we don't have that button hooked up to anything. So what we're going to want to do is go back to our frontend and specifically we'll want to open up the ProductDetailPage which is where our button is defined. And what we're going to want to have happen is when a user clicks this button, it's going to need to make a request, right? The right kind of request with the correct payload to our server. So the first thing we'll want to do is add a directive to our button, which we'll link it up to a method. And we can do that, by the way…

Contents