Create vuex modules for Films/Vehicles/Locations/People + Test adaptation

This commit is contained in:
2020-12-21 12:01:36 +01:00
parent d8cfe69fa0
commit fffbc87964
12 changed files with 172 additions and 95 deletions

25
store/locations/index.js Normal file
View File

@@ -0,0 +1,25 @@
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.");
}
}
};
export const getters = {
location: state => state.location
};