-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-lambda.js
More file actions
64 lines (55 loc) · 1.32 KB
/
Copy pathtest-lambda.js
File metadata and controls
64 lines (55 loc) · 1.32 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
const https = require('https');
const testData = {
userId: "testuser1",
username: "Test User",
email: "test@example.com",
totalSpent: 1200,
totalIncome: 3000,
transactionCount: 15,
categories: {
"Food": 300,
"Transportation": 200,
"Entertainment": 150,
"Shopping": 550
},
month: "2024-01",
timestamp: new Date().toISOString(),
timezone: "America/New_York"
};
const postData = JSON.stringify(testData);
const options = {
hostname: '886l7lx4xj.execute-api.us-east-2.amazonaws.com',
path: '/default/getFinanceAIInsights',
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Content-Length': postData.length
},
timeout: 5000
};
const req = https.request(options, (res) => {
console.log('Status:', res.statusCode);
console.log('Headers:', res.headers);
let data = '';
res.on('data', (chunk) => {
data += chunk;
});
res.on('end', () => {
console.log('Response:', data);
try {
const parsed = JSON.parse(data);
console.log('Parsed:', JSON.stringify(parsed, null, 2));
} catch(e) {
console.log('Could not parse JSON:', e.message);
}
});
});
req.on('error', (error) => {
console.error('Request error:', error);
});
req.on('timeout', () => {
console.error('Request timeout');
req.destroy();
});
req.write(postData);
req.end();