add an action to get coaches from firebase

This commit is contained in:
Andreas Zweili 2021-07-28 16:58:14 +02:00
parent f1ed21f3f0
commit 4665d05bfa
2 changed files with 21 additions and 0 deletions

View File

@ -21,6 +21,24 @@ export default {
} catch (err) {
console.log(err.response.status);
}
},
async loadCoaches(context) {
try {
const response = await getAPI.get('coaches.json');
const responseData = response.data;
const coaches = [];
for (const key in responseData) {
const coach = {
id: key,
firstName: responseData[key].firstName,
lastName: responseData[key].lastName,
description: responseData[key].description,
hourlyRate: responseData[key].hourlyRate,
areas: responseData[key].areas
};
coaches.push(coach);
}
context.commit('setCoaches', coaches);
} catch (err) {
console.log(err.response.status);
}

View File

@ -1,5 +1,8 @@
export default {
registerCoach(state, payload) {
state.coaches.push(payload);
},
setCoaches(state, payload) {
state.coaches = payload;
}
};