front correction id number|null

This commit is contained in:
trochas
2026-01-09 17:49:35 +01:00
parent 7a2b72e0b1
commit aa21d046cf
6 changed files with 29 additions and 24 deletions

View File

@@ -210,10 +210,14 @@ export async function getAllUserAPI(): Promise<User[]> {
}
}
export async function getCoachByIdAPI(id:number): Promise<Coach|null> {
export async function getCoachByIdAPI(id:number|null): Promise<Coach|null> {
try{
const response = await coachService.getById(id);
return new Coach(response.data);
if(id!==null){
const response = await coachService.getById(id);
return new Coach(response.data);
}
console.error("Error fetching coach by id : id null");
return null;
}catch (error) {
console.error("Error fetching coach by id:", error);
return null;