frontend/lib: add method to update user

Pedro Lucas Porcellis porcellis@eletrotupi.com 1 month ago 17207313f44cdecf0de608083d71bbfaabc87bf5
Parents: 4ad3b1e
1 file(s) changed
  • frontend/lib/api.ts +10 -1
frontend/lib/api.ts
@@ -8,11 +8,16 @@ id: number;
8 8 email: string;
9 9 firstName: string;
10 10 lastName?: string;
11 + updatedAt: Date;
11 12 }
12 13
13 14 export interface AuthResponse {
14 15 token: string;
15 16 user: User;
17 + }
18 +
19 + export interface UserUpdateResponse {
20 + user: User
16 21 }
17 22
18 23 class ApiClient {
@@ -60,7 +65,11 @@
60 65 const response = await fetch(`${API_BASE_URL}${endpoint}`, config);
61 66
62 67 if (!response.ok) {
63 - const error = await response.json().catch(() => ({ error: 'Network error' }));
68 + const error = await response.json()
69 + .catch(() => ({ error: 'Network error' }));
70 +
71 + console.error("[API]: ", error, response.status)
72 +
64 73 throw new Error(error.error || `HTTP ${response.status}`);
65 74 }
66 75