-
Notifications
You must be signed in to change notification settings - Fork 0
/
AxiosRequestsFunctions.js
57 lines (39 loc) · 1.08 KB
/
AxiosRequestsFunctions.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
47
48
49
50
51
52
53
54
55
56
57
const axios = require('axios');
let mysql = require('mysql');
var moment = require('moment');
// Script to send post queries to other servers
class AxiosHandler {
connection;
contract;
web3;
constructor() {
console.log('axioshandler started with success');
}
// --------- MAIN FUNCTIONS ---------- //
async getcall(url){
return new Promise(async (resolve, reject) => {
await axios.get(url)
.then(resp => {
resolve('ok');
})
.catch(error => {
console.log('getcall error: ', error);
reject(error.error);
});
});
}
async postcall(url, jsondata){
return new Promise(async (resolve, reject) => {
await axios.post(url, jsondata)
.then(resp => {
resolve('ok');
})
.catch(error => {
console.log('postcall error: ', error);
reject(error.error);
});
});
}
}
let newwaxiosHanlder = new AxiosHandler();
module.exports = AxiosHandler; // Export class