-
Notifications
You must be signed in to change notification settings - Fork 0
/
comunicador.js
61 lines (42 loc) · 1.5 KB
/
comunicador.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
58
59
60
61
const fetch = require("node-fetch");
const servidor = "https://www.sapocomprador.com.br/controler.php";
module.exports = {
submeter: async function (dad,ac) {
// console.log("SUBMETENDO>> "+ac);
let dd = dad;
// let dd = JSON.parse(dad);
// dd["seguranca"] = 'sim';
// console.log("O DD",dd);
let conteudo = {acao:ac,dados:dd};
// console.log("Content>>>",conteudo);
const rawResponse = await fetch(servidor, {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify(conteudo)
});
//console.log("RAW:",rawResponse);
const content = await rawResponse.json();
return content;
},
submeterDestino: async function (dad,ac,destino) {
// console.log("SUBMETENDO>> "+ac,destino );
let dd = JSON.parse(dad);
dd["seguranca"] = 'sim';
// console.log("O DD",dd);
let conteudo = {acao:ac,dados:JSON.stringify(dd),seguranca:'sim'};
// console.log("Content>>>",conteudo);
const rawResponse = await fetch(destino, {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify(conteudo)
});
const content = await rawResponse.json();
return content;
}
};