const http = require('http'); const querystring = require('querystring'); const base = { hostname: '127.0.0.1', port: 8090, path: '/do', method: 'POST' }; async function call(form){ const postData = querystring.stringify(form); const options = Object.assign(base, { headers: { 'Content-Type': 'application/x-www-form-urlencoded', 'Content-Length': Buffer.byteLength(postData) } }) return new Promise((cbok, cberr)=>{ const req = http.request(options, (res) => { let data = ''; res.on('error', (e)=>{ cberr(e) }) res.on('data', (chunk) => { data += chunk; }); res.on('end', () => { console.log(data); cbok(data) }); }); req.write(postData); req.end(); }) } export default { call }