Skip to content

Commit 7832734

Browse files
authored
Merge pull request #42 from adity1raut/aditya-side
Improve error handling and include credentials in apiFetch
2 parents 059afe6 + 694dc22 commit 7832734

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

client/src/utils/aiUtils.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ export async function post(path, body) {
1515
body: JSON.stringify(body),
1616
});
1717
if (!res.ok) {
18-
const err = await res
19-
.json()
20-
.catch(() => ({ detail: `HTTP ${res.status}` }));
21-
throw new Error(err.detail || `HTTP ${res.status}`);
18+
const err = await res.json().catch(() => ({ error: `HTTP ${res.status}` }));
19+
throw new Error(
20+
err.error || err.detail || err.message || `HTTP ${res.status}`,
21+
);
2222
}
2323
return res.json();
2424
}

client/src/utils/api.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export const API_URL = import.meta.env.VITE_API_URL || "";
22

33
export function apiFetch(path, options = {}) {
4-
return fetch(`${API_URL}${path}`, options);
4+
return fetch(`${API_URL}${path}`, { credentials: "include", ...options });
55
}

0 commit comments

Comments
 (0)