Reducing Vuex boilerplate for AJAX calls

Reducing Vuex boilerplate for AJAX calls

So far, we have createAsyncMutation and doAsync . Assuming we export them from wherever file they were defined, we can use in our store like such:

[…]

Actually, we will just generate one mutation, using the BASE property from the object return from createAsyncMutation. In the mutation, we will handle SUCCESS, FAILURE, and PENDING using a switch statement.

[…]