Removed auth from stats

This commit is contained in:
Nicolai Ort 2021-08-18 17:28:31 +02:00
parent f4ec2fe472
commit 1cc0c2ce76
Signed by: niggl
GPG Key ID: 13AFA55AF62F269F
1 changed files with 19 additions and 3 deletions

View File

@ -1,11 +1,19 @@
import axios from 'axios';
import UserStore from './UserStore';
axios.interceptors.response.use(response => {
return response;
}, error => {
if (error.response.status === 401) {
UserStore.logout();
}
return error;
});
export default class Apiclient {
static async getStats() {
return (
await axios.get('https://kauft.es/api/stats', {
headers: { Authorization: `Bearer ${UserStore.state.token}` }
})
await axios.get('https://kauft.es/api/stats')
).data;
}
@ -50,4 +58,12 @@ export default class Apiclient {
})
).data;
}
static async logout() {
return (
await axios.post(`https://kauft.es/api/auth/logout`, {}, {
headers: { Authorization: `Bearer ${UserStore.state.token}` }
})
).data;
}
}