-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi-test.js
More file actions
42 lines (28 loc) · 897 Bytes
/
api-test.js
File metadata and controls
42 lines (28 loc) · 897 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
34
35
36
37
38
39
40
41
42
const request = require('request');
const BASE_URL = 'http://localhost:3000';
const postTransact = ({ to, value }) => {
return new Promise((resolve, reject) => {
request(`${BASE_URL}/account/transact`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ to, value })
},(error, response, body) => {
return resolve(JSON.parse(body));
});
});
}
postTransact({})
.then(postTransactResponse => {
console.log(
'postTransactResponse (Create Account Transaction)',
postTransactResponse
);
const toAccountData = postTransactResponse.transaction.data.accountData;
return postTransact({ to: toAccountData.address, value: 20 });
})
.then(postTransactResponse2 => {
console.log(
'postTransactResponse2 (Standard Transaction)',
postTransactResponse2
);
})