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 { export default {
userId(state) { userId(state) {
return state.userId; return state.userId;
},
token(state) {
return state.token;
} }
}; };

View File

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

View File

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