add an action to get coaches from firebase
This commit is contained in:
parent
f1ed21f3f0
commit
4665d05bfa
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
export default {
|
||||
registerCoach(state, payload) {
|
||||
state.coaches.push(payload);
|
||||
},
|
||||
setCoaches(state, payload) {
|
||||
state.coaches = payload;
|
||||
}
|
||||
};
|
||||
|
|
Reference in New Issue