-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-current-error.js
More file actions
46 lines (39 loc) · 1.37 KB
/
Copy pathtest-current-error.js
File metadata and controls
46 lines (39 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Direct test to see the actual current error
const fs = require('fs');
const testCurrentState = async () => {
console.log('Testing current API state...\n');
try {
const response = await fetch('http://localhost:3000/api/analyze', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
code: 'function test() { return 1; }',
complexity: 'beginner'
})
});
console.log(`HTTP Status: ${response.status}\n`);
const text = await response.text();
console.log('Raw Response:');
console.log(text);
console.log('\n---\n');
if (!response.ok) {
console.log('\n❌ ERROR DETAILS:');
try {
const error = JSON.parse(text);
console.log(JSON.stringify(error, null, 2));
if (error.details) {
fs.writeFileSync('last-error-trace.txt', error.details);
console.log('\n✅ Error details written to last-error-trace.txt');
}
} catch (e) {
console.log('Response is not JSON:', text);
}
}
} catch (error) {
console.log('\n❌ FETCH FAILED:');
console.log('Error:', error.message);
}
};
testCurrentState();