26 lines
547 B
JavaScript
26 lines
547 B
JavaScript
export const state = () => ({
|
|
location: {}
|
|
});
|
|
|
|
export const mutations = {
|
|
setLocation: (state, location) => {
|
|
state.location = location;
|
|
}
|
|
};
|
|
|
|
export const actions = {
|
|
async getLocation({ commit }, { id, callback = false }) {
|
|
try {
|
|
const location = await this.$axios.$get(`/api/locations/${id}`);
|
|
if (callback) return location;
|
|
commit("setLocation", location);
|
|
} catch (e) {
|
|
throw Error(`API Error occurred: ${e.message}`);
|
|
}
|
|
}
|
|
};
|
|
|
|
export const getters = {
|
|
location: state => state.location
|
|
};
|