Skip to content

Instantly share code, notes, and snippets.

@gkarugi
Created May 8, 2018 18:16
Show Gist options
  • Save gkarugi/805ee5f9d4306ac295c875b2ba6893ec to your computer and use it in GitHub Desktop.
Save gkarugi/805ee5f9d4306ac295c875b2ba6893ec to your computer and use it in GitHub Desktop.
import Vue from 'vue';
import Vuex from 'vuex';
import axios from 'axios';
Vue.use(Vuex);
const tenantWebsiteStore = new Vuex.Store({
state: {
website: []
},
mutations: {
FETCH(state, website) {
state.website = website;
},
},
actions: {
fetch({ commit }) {
return axios.get('/spaApi/tenantWebsite')
.then(response => commit('FETCH', response.data))
.catch();
},
},
getters: {
websiteName: state => {
return state.website.data.attributes.name
},
websiteLogoUrl: state => {
return state.website.data.attributes.logo_url
}
},
});
export default tenantWebsiteStore;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment