debug api

This commit is contained in:
trochas
2026-01-07 13:50:50 +01:00
parent bb4c0f67ad
commit abbf4cb726
4 changed files with 17 additions and 104 deletions

View File

@@ -12,6 +12,7 @@ api.interceptors.request.use((config) => {
if (keycloak?.token) {
// eslint-disable-next-line no-param-reassign
config.headers.Authorization = `Bearer ${keycloak.token}`;
console.log(config.headers.Authorization);
}
return config;
});

View File

@@ -1,9 +1,12 @@
import { getUsersAPI } from "../requetes"
import { useKeycloak } from "@react-keycloak/web"
import { getCoachsAPI, getUsersAPI } from "../requetes"
function TestAPI(){
const { keycloak } = useKeycloak()
function handleGetUsers(): void {
getUsersAPI()
getCoachsAPI();
}
return(

View File

@@ -1,14 +1,5 @@
import api from "./api";
import { Activite, Athlete, Coach, Session, User } from "./classes";
//import { useKeycloak } from '@react-keycloak/web'
//const { keycloak } = useKeycloak()
/*
const useAuthHeader = () => {
return keycloak?.token
? { Authorization: `Bearer ${keycloak.token}` }
: {}
}*/
//debug:
export function delay(ms: number): Promise<void> {
@@ -146,4 +137,14 @@ export async function getUsersAPI(): Promise<User[]> {
console.error("Error fetching users:", error);
throw error;
}
}
export async function getCoachsAPI(): Promise<Coach[]> {
try {
const response = await api.get<Coach[]>("/coach/all");
return response.data;
} catch (error) {
console.error("Error fetching coachs:", error);
throw error;
}
}