The third key part of Vuex is called actions. Actions are methods, just as mutations are, but they can perform asynchronous code within them.Â
Actions receive two parameters as follows:
- The first one is a context, which is an object that holds a reference to the state, the getters, and the ability to commit mutations and dispatch other actions.
- The second (optional) parameter is user-defined; means that we can send extra information to our actions if we need it, but this can also be safely ignored.
A common pattern in Vuex-powered applications is to keep HTTP calls inside Vuex actions—that way, they can be dispatched by any component inside the application if they are needed. These HTTP calls usually modify or make use of the state, which is very convenient since we have this all available through the context.Â
Let's go back to the...