-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-api.js
More file actions
49 lines (42 loc) · 1.28 KB
/
Copy pathtest-api.js
File metadata and controls
49 lines (42 loc) · 1.28 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
47
48
49
// Simple test script to verify API functionality
const testChat = async () => {
try {
console.log('Testing chat API...');
const response = await fetch('http://localhost:3000/api/chat', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
message: 'Hello, can you tell me about NASA research?'
})
});
const data = await response.json();
if (response.ok) {
console.log('✅ Chat API working!');
console.log('Response:', data.message.substring(0, 100) + '...');
} else {
console.log('❌ Chat API error:', data.error);
}
} catch (error) {
console.log('❌ Network error:', error.message);
}
};
const testSuggestions = async () => {
try {
console.log('Testing suggestions API...');
const response = await fetch('http://localhost:3000/api/suggestions?topic=astrobiology');
const data = await response.json();
if (response.ok) {
console.log('✅ Suggestions API working!');
console.log('Suggestions:', data.suggestions);
} else {
console.log('❌ Suggestions API error:', data.error);
}
} catch (error) {
console.log('❌ Network error:', error.message);
}
};
// Run tests
testChat();
testSuggestions();