-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-api.ts
More file actions
34 lines (31 loc) · 820 Bytes
/
test-api.ts
File metadata and controls
34 lines (31 loc) · 820 Bytes
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
import axios from 'axios';
async function testApi() {
try {
console.log('Testing API...');
const response = await axios.post('http://127.0.0.1:3000/mcp', {
tool: 'fetchLeaderboard',
params: {
type: 'heroes'
}
}, {
headers: {
'Content-Type': 'application/json'
}
});
console.log('Response:', response.data);
} catch (error) {
if (axios.isAxiosError(error)) {
console.error('Error:', error.response?.data || error.message);
console.error('Error details:', {
code: error.code,
status: error.response?.status,
statusText: error.response?.statusText,
headers: error.response?.headers,
data: error.response?.data
});
} else {
console.error('Error:', error);
}
}
}
testApi();