mirror of
https://github.com/hay-kot/homebox.git
synced 2024-11-16 13:48:44 +00:00
logger
This commit is contained in:
parent
5f589f95b8
commit
3fda815634
1 changed files with 3 additions and 7 deletions
|
@ -3,12 +3,8 @@ import { UserApi } from '~~/lib/api/user';
|
||||||
import { Requests } from '~~/lib/requests';
|
import { Requests } from '~~/lib/requests';
|
||||||
import { useAuthStore } from '~~/stores/auth';
|
import { useAuthStore } from '~~/stores/auth';
|
||||||
|
|
||||||
function ApiDebugger(r: Response) {
|
function logger(r: Response) {
|
||||||
console.table({
|
console.log(`${r.status} ${r.url} ${r.statusText}`);
|
||||||
'Request Url': r.url,
|
|
||||||
'Response Status': r.status,
|
|
||||||
'Response Status Text': r.statusText,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function usePublicApi(): PublicApi {
|
export function usePublicApi(): PublicApi {
|
||||||
|
@ -20,7 +16,7 @@ export function useUserApi(): UserApi {
|
||||||
const authStore = useAuthStore();
|
const authStore = useAuthStore();
|
||||||
|
|
||||||
const requests = new Requests('', () => authStore.token, {});
|
const requests = new Requests('', () => authStore.token, {});
|
||||||
requests.addResponseInterceptor(ApiDebugger);
|
requests.addResponseInterceptor(logger);
|
||||||
requests.addResponseInterceptor(r => {
|
requests.addResponseInterceptor(r => {
|
||||||
if (r.status === 401) {
|
if (r.status === 401) {
|
||||||
authStore.clearSession();
|
authStore.clearSession();
|
||||||
|
|
Loading…
Reference in a new issue