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