Skip to content

Instantly share code, notes, and snippets.

@luiscberrocal
Created January 15, 2019 22:23
Show Gist options
  • Save luiscberrocal/6c20ac94e3946081a17b3e7504b1990d to your computer and use it in GitHub Desktop.
Save luiscberrocal/6c20ac94e3946081a17b3e7504b1990d to your computer and use it in GitHub Desktop.
vuejs module template
const state = {
$STATE$: [],
}
const getters = {
$STATE$: state => {
return state.$STATE$;
},
}
const mutations = {
set$STATE_UP$(state, $STATE$) {
state.$STATE$ = $STATE$;
},
}
const actions = {
get$STATE_UP$({commit, getters}, $FILTER_VAL$) {
const JWTToken = getters.jwt;
const headers = {headers: {"Authorization": `Bearer ${JWTToken}`}}
axios.get(`/my/url/${$FILTER_VAL$}`, headers)
.then((response) => {
console.log(response.data);
commit('set$STATE_UP$', response.data);
})
.catch((error) => {
console.log(error)
})
},
}
export default {
state,
mutations,
actions,
getters
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment