Skip to content

Commit 2b29c30

Browse files
committed
fix: enhanced JSON parsing and raw-text logging in front-end
1 parent 62598a6 commit 2b29c30

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

web/src/App.jsx

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,24 @@ function App() {
3232
});
3333
console.log('Response status:', res.status);
3434
if (res.ok) {
35-
const json = await res.json().catch((e) => {
36-
console.error('Failed to parse JSON from 200 response:', e);
37-
return {};
38-
});
39-
console.log('Parsed JSON:', json);
40-
setData(json);
41-
setIsFallback(false);
35+
// Attempt to read raw text for debugging
36+
let text = '';
37+
try {
38+
text = await res.text();
39+
console.log('Raw 200 response text:', text);
40+
const json = JSON.parse(text);
41+
console.log('Parsed JSON:', json);
42+
setData(json);
43+
setIsFallback(false);
44+
setError('');
45+
return;
46+
} catch (e) {
47+
console.error('Error parsing JSON from 200 response:', e);
48+
console.error('Response text was:', text);
49+
setError('Invalid JSON response from server');
50+
setLoading(false);
51+
return;
52+
}
4253
} else if (res.status === 422) {
4354
// Validation error: fallback flow
4455
let errJson = {};

0 commit comments

Comments
 (0)