Created
July 20, 2016 12:34
-
-
Save danielschmitz/65e0e70ca9434e9739ded8d271e97a91 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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