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: ${e.message}`); } } }; export const getters = { vehicle: state => state.vehicle };