All your mutations must be synchronous, so how do you do things such as waiting for a timeout or using Axios for an AJAX request? Actions are the next level of abstraction that will help you with this. Inside an action, you can commit multiple mutations and make asynchronous operations.
Mutations are the building blocks of actions, so it's highly suggested you complete the preceding recipe before trying this.
We will be using the setup from the Building a simple storage for the application state recipe; you can use your own as well, but in any case this recipe is based on a slight modification of the official Webpack template.
You will build a clone of the popular Xkcd website. Actually, it will be a wrapper more than a real clone, since we will reuse the panels from the website.
Create a Vue project based on the Webpack template with vue init webpack
. The first thing we will do is wire up the API to the Xkcd website in the index.js
inside...