-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathnode-example.js
More file actions
33 lines (31 loc) · 925 Bytes
/
node-example.js
File metadata and controls
33 lines (31 loc) · 925 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
const GravitApi = require('../src');
// User data
const wsUrl = 'ws://localhost:9274/api';
const userdata = {
login: 'test',
password: 'test'
};
// Api usage example
const api = new GravitApi();
api.connect(wsUrl)
.then(() => {
api.send('getAvailabilityAuth').then(auth => {
console.log(auth.list);
auth = auth.list.pop();
console.log(`Выбран первый профиль авторизации: ${auth.displayName}`);
api.send('auth', {
login: userdata.login,
password: {
password: userdata.password,
type: "plain"
},
auth_id: auth.name,
getSession: false,
authType: "API",
initProxy: false
}).then(res => {
console.log(res);
api.close();
}).catch(console.error);
}).catch(console.error);
}).catch(console.error);