Skip to content

Instantly share code, notes, and snippets.

@danielschmitz
Created July 20, 2016 12:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielschmitz/65e0e70ca9434e9739ded8d271e97a91 to your computer and use it in GitHub Desktop.
Save danielschmitz/65e0e70ca9434e9739ded8d271e97a91 to your computer and use it in GitHub Desktop.
export function loadCategories({dispatch, state},keyword) {
dispatch('SHOW_LOADING')
let start = (state.category.page * state.itens_per_page) - (state.itens_per_page - 1);
let keywordString=""
if (keyword!=null){
keywordString=`&q=${keyword}`
}
this.$http.get(`${URL}/categories?start=${start}&limit=${state.itens_per_page}${keywordString}`).then(
response => {
dispatch("SET_CATEGORIES", response.json())
dispatch('SET_TOTAL_CATEGORIES', response.headers['x-total-count']);
},
error => {
dispatch("SHOW_ERROR", error.body)
}
).finally(function () {
dispatch("HIDE_LOADING")
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment