To start our component, we will use the Vue project with Vue-CLI that we used in the 'Creating and understanding the Vuex getters' recipe, or we can start a new one.
To start a new one, open Terminal (macOS or Linux) or Command Prompt/PowerShell (Windows) and execute the following command:
> vue create vuex-store
Choose the manual features, and add Router and Vuex as required features, as indicated in the 'How to do it... section of the 'Creating a simple Vuex store' recipe.
Now follow these steps to create the Vuex actions:
- Create a new file called actions.js in the src/store/user folder.
- Import the mutation types files (types.js), and the getHttp, patchHttp, postHttp, and deleteHttp functions from the fetchApi wrapper:
import {
getHttp,
patchHttp,
deleteHttp,
postHttp,
} from '@/http/fetchApi';
import MT from './types';
- Create a new asynchronous function called createUser, which receives as the first argument a deconstructed...