provide the auth token with limited requests

This commit is contained in:
Andreas Zweili 2021-07-29 16:51:48 +02:00
parent beb804e38c
commit 2eb4651aa4
3 changed files with 20 additions and 3 deletions

View File

@ -1,5 +1,8 @@
export default {
userId(state) {
return state.userId;
},
token(state) {
return state.token;
}
};

View File

@ -12,8 +12,14 @@ export default {
areas: data.areas
};
const token = context.rootGetters.token;
const axiosConfig = {
params: { auth: token }
};
try {
await getAPI.put(`coaches/${userId}.json`, coachData);
console.log(axiosConfig);
await getAPI.put(`coaches/${userId}.json`, coachData, axiosConfig);
context.commit('registerCoach', {
...coachData,
id: userId

View File

@ -21,9 +21,17 @@ export default {
}
},
async fetchRequests(context) {
const coachId = context.rootGetters.userId;
const token = context.rootGetters.token;
const axiosConfig = {
params: { auth: token }
};
try {
const coachId = context.rootGetters.userId;
const response = await getAPI.get(`requests/${coachId}.json`);
const response = await getAPI.get(
`requests/${coachId}.json`,
axiosConfig
);
const responseData = await response.data;
const requests = [];