fetch_items(context) {
return axios.get(path_to_items)
.then(res => {
context.commit('set_items', res.data)
setTimeout(() => {
context.dispatch('fetch_items')
}, 1*60*1000)
})
}
data() {
return {
games: {},
firstLoad: true
}
},
created() {
this.getGames()
},
watch: {
'games.current_page': function(){
if(!this.firstLoad) this.getGames(this.games.current_page)
}
},
methods: {
getGames(page) {
var page = this.games.current_page || 1
this.axios.get('/api/v1/games?page=' + page)
.then(response => {
this.games = response.data
this.$nextTick(()=> {this.firstLoad = false})
console.log(response.data)
})
.catch(err => console.log(err))
}
}
this.$store.dispatch('some action')
.then((res) => {
// if need alert
this.$snotify.info('Some message')
})