farther debugging for users

This commit is contained in:
2025-10-09 23:28:35 +02:00
parent 8b4886e5bd
commit 6a9ddea0c5
4 changed files with 34 additions and 8 deletions

View File

@@ -13,15 +13,27 @@ const getAuthHeaders = () => {
export class EmployeeService {
async getEmployees(): Promise<Employee[]> {
console.log('🔄 Fetching employees from API...');
const token = localStorage.getItem('token');
console.log('🔑 Token exists:', !!token);
const response = await fetch(`${API_BASE_URL}/employees`, {
headers: getAuthHeaders(),
});
console.log('📡 Response status:', response.status);
if (!response.ok) {
const errorText = await response.text();
console.error('❌ API Error:', errorText);
throw new Error('Failed to fetch employees');
}
return response.json();
const employees = await response.json();
console.log('✅ Employees received:', employees.length);
return employees;
}
async getEmployee(id: string): Promise<Employee> {