-
Notifications
You must be signed in to change notification settings - Fork 20
/
SEP31.js
43 lines (37 loc) · 1.19 KB
/
SEP31.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
const fetch = require('node-fetch');
const StellarSdk = require('stellar-sdk');
const querystring = require('querystring');
const networkPassphrase = 'Public Global Stellar Network ; September 2015';
const url = 'https://api.cowrie.exchange/sep31/direct/transactions';
module.exports = {
send: (remittance, jwt) => {
var post = JSON.stringify(remittance);
var api = url;
console.log(api);
console.log(post);
var remit = fetch(
api, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${jwt}`
},
body: post
}
).then((response) => {
console.log('HTTP: ' + response.status);
if(response.status == 200) {
return response.json();
}
else {
throw response.ststausText;
}
}).then((body) => {
//console.log('body: ' + JSON.stringify(body));
return body;
}).catch((error) => {
console.log(error);
});
return remit;
}
}