-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.js
41 lines (34 loc) · 918 Bytes
/
api.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
const axios = require('axios');
const e = require('express');
/// PLease dont Uncomment this
async function asyncAxiosCall(url, body, socket) {
console.log("Posting with body:",body,"URL:",url)
const outputPromise = new Promise(function (accept, reject) {
socket.on(body.channels[body.channels.length - 1], res => {
let result = JSON.parse(JSON.parse(res));
accept(result.data);
});
}).then(
function (value) {
return value;
}
).catch(error => {
console.log(error);
});
axios.post(url, body);
const output = await outputPromise;
return output;
}
function axiosCall(url, body) {
console.log("Posting with body:",body,"URL:",url)
return axios.post(url, body)
}
function axiosGetCall(url) {
console.log("Posting with ","URL:",url)
return axios.get(url)
}
module.exports = {
asyncAxiosCall,
axiosCall,
axiosGetCall
};