fetchBuilder(url) {
return this.$http.get(url).then((responce) => {
return response;
}).catch((error) => {
if (error.response.status == 403) {
this.redirectLogin();
}
});
};
this.fetchBuilder('/api/messages?uid=' + uid ).then(r => {
this.messages = r
})
<template>
<preloader @show="show = $event"></preloader>
<header v-if="!show"></header>
</template>
export default {
data() {
return {
show: true
}
}
}
<template>
<button @click="handler"></button>
</template>
export default {
data() {
return {
show: false
}
},
methods: {
handler() {
this.show = !this.show
this.$emit('show', this.show)
}
}
}
store.dispatch('urrent_user')
.then(r => {
// next processing
})
.catch(e => {
// goto login
})
{
state: {
currentLang: 'RU',
translations: {
RU: {
label1: 'some ru text',
label2: 'some ru text',
},
EN: {
label1: 'some en text',
label2: 'some en text',
}
}
},
getters: {
translate: (state) => (label) => {
return state.translations[state.currentLang][label]
}
}
}
this.$store.getters.translate('label1')
sendWithCheck(action1,action2, params) {
this.$store.dispatch(action1, params)
.then(r => {
if(r.result) {
showConfirmMessage('textmessage', () => {
// this is confirm event handler just for example
this.$store.dispatch(action2)
})
} else {
this.$store.dispatch(action2)
}
})
}