forked from domdomegg/airtable-mcp-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathservice-test2.js
More file actions
44 lines (37 loc) · 1.21 KB
/
Copy pathservice-test2.js
File metadata and controls
44 lines (37 loc) · 1.21 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
import nodeFetch from 'node-fetch';
// More closely resembles AITableService
class TestService {
constructor(
apiKey = process.env.AITABLE_API_KEY || '',
baseUrl = 'https://api.aitable.ai',
fetch = nodeFetch
) {
console.log('Constructor called with:');
console.log('- apiKey:', apiKey.substring(0, 5) + '...');
console.log('- baseUrl:', baseUrl);
console.log('- fetch type:', typeof fetch);
this.apiKey = apiKey;
this.baseUrl = baseUrl;
this.fetch = fetch;
}
async testFetch() {
console.log('Testing fetch inside the class...');
console.log('this.fetch type:', typeof this.fetch);
try {
const response = await this.fetch('https://example.com');
console.log('Fetch successful! Status:', response.status);
return true;
} catch (error) {
console.error('Error in fetch:', error);
return false;
}
}
}
// Test with the parameters we're using in test-service.js
async function runTest() {
const apiKey = process.env.AITABLE_API_KEY || 'test-key';
// This mirrors our current usage in test-service.js
const service = new TestService(apiKey, 'https://api.aitable.ai', nodeFetch);
await service.testFetch();
}
runTest();