-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathseed.js
46 lines (38 loc) · 1021 Bytes
/
seed.js
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
const Hamoni = require("hamoni-sync");
const https = require("https");
const accountId = "YOUR_ACCOUNT_ID";
const appId = "YOUR_APP_ID";
let hamoni;
const data = JSON.stringify({ accountId, appId });
const options = {
hostname: "api.sync.hamoni.tech",
path: "/v1/token",
method: "POST",
headers: {
"Content-Type": "application/json",
"Content-Length": data.length
}
};
const req = https.request(options, res => {
console.log(`statusCode: ${res.statusCode}`);
res.on("data", token => {
hamoni = new Hamoni(token);
hamoni
.connect()
.then(response => {
hamoni
.createList("datagrid", [
{ firstName: "James", lastName: "Darwin" },
{ firstName: "Jimmy", lastName: "August" }
])
.then(() => console.log("create success"))
.catch(error => console.log(error));
})
.catch(error => console.log(error));
});
});
req.on("error", error => {
console.error(error);
});
req.write(data);
req.end();