add the backend to the register form

This commit is contained in:
Andreas Zweili 2021-07-28 16:36:52 +02:00
parent 99ec687332
commit d716c7efd0
1 changed files with 15 additions and 2 deletions

View File

@ -1,5 +1,8 @@
import getAPI from '../../../scripts/axios-api';
export default {
registerCoach(context, data) {
async registerCoach(context, data) {
const userId = context.rootGetters.userId;
const coachData = {
id: context.rootGetters.userId,
firstName: data.first,
@ -8,6 +11,16 @@ export default {
hourlyRate: data.rate,
areas: data.areas
};
context.commit('registerCoach', coachData);
try {
await getAPI.put(`coaches/${userId}.json`, coachData);
} catch (err) {
console.log(err.response.status);
}
context.commit('registerCoach', {
...coachData,
id: userId
});
}
};