mutations SET_NAME state name state name name actions SET_NAME async c

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
mutations: {
SET_NAME: (state, name) => {
state.name = name;
},
},
actions: {
SET_NAME: async (context, name) => {
let {data} = await Axios.post('http://myapiendpoint.com/api/name', {name: name});
if (data.status == 200) {
context.commit('SET_NAME', name);
}
},
}