Add another function to methods
section of cart.js
called checkOut
. It should:
Create a Sale
domain object. The following code shows you how to do this:
let sale = new Sale(this.customer, this.items);
POST the sale object to the /api/sales
path of the web service.
Reset the items array to prevent accidental double orders. The following data store mutation can be used to do this:
// clear cart items clearItems(state) { state.items = new Array(); }
Call the mutation via the usual commit
call in the then
callback of the Axios request.