-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest.js
More file actions
44 lines (37 loc) · 1.32 KB
/
test.js
File metadata and controls
44 lines (37 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
// test.js
import BinanceAPI from 'binance-api-node';
import dotenv from 'dotenv';
dotenv.config();
// Sprawdź, co faktycznie importujesz
console.log('BinanceAPI:', BinanceAPI);
// Jeśli BinanceAPI jest obiektem z domyślnym eksportem, użyj `BinanceAPI.default`
const Binance = BinanceAPI.default || BinanceAPI;
const client = Binance({
apiKey: process.env.BINANCE_API_KEY,
apiSecret: process.env.BINANCE_API_SECRET,
});
async function getServerTime() {
try {
const serverTime = await client.time();
console.log('Raw server time:', serverTime); // Dodany log
const localTime = Date.now();
const diff = serverTime.serverTime - localTime;
console.log(`Server Time: ${new Date(serverTime.serverTime).toISOString()}`);
console.log(`Local Time: ${new Date(localTime).toISOString()}`);
console.log(`Time Difference (server - local): ${diff} ms`);
} catch (error) {
console.error('Error fetching server time:', error);
}
}
async function testConnection() {
try {
const accountInfo = await client.accountInfo();
console.log('Account Info:', accountInfo);
} catch (error) {
console.error('Error connecting to Binance:', error);
}
}
// Najpierw pobierz serwerowy czas, a potem testuj połączenie
getServerTime().then(() => {
testConnection();
});