-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
39 lines (33 loc) · 925 Bytes
/
test.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
var FormData = require('form-data');
var form = new FormData();
function finishWithError(message) {
console.log(message);
core.setFailed(message);
}
function submit(form) {
return new Promise((resolve, reject) => {
var data = "";
form.submit("https://slack.com/api/files.upload", (err, res) => {
if(err) {
reject(err);
} else {
res.on("data", (chunk) => { data += chunk;});
res.on("end", () => {
data = JSON.parse(data);
console.log(data);
if(data.ok) {
resolve(data);
} else {
reject(data.error);
}
});
}
});
});
}
async function run() {
var form = new FormData();
await submit(form);
}
run();
console.log("___________");