Files
ghibli-api/store/vehicles/index.js

26 lines
521 B
JavaScript

export const state = () => ({
vehicle: {}
});
export const mutations = {
setVehicle: (state, vehicle) => {
state.vehicle = vehicle;
}
};
export const actions = {
async getvehicle({ commit }, { id, callback = false }) {
try {
const vehicle = await this.$axios.$get(`/api/vehicles/${id}`);
if (callback) return vehicle;
commit("setVehicle", vehicle);
} catch (e) {
throw Error("API Error occurred.");
}
}
};
export const getters = {
vehicle: state => state.vehicle
};