利用Nodejs Http 發送資料
const http = require('http');
const querystring = require("querystring");

var data = {
username: 'abc',
password: 'cdf'
};

var buffer = '';

//填寫header
const options = {
hostname: 'localhost',
port: 80,
path: "/login",
method: 'POST',
headers:{
'Content-Type': 'application/x-www-form-urlencoded' ,
'Content-Length' : data.length
},
Accept:'application/xml, text/xml, */*'
};

//建立連線
var req = http.request(options, function(res) {
//接收localhost回傳資料流
res.on('data', function (chunk) {
buffer += chunk;
});
res.on('end', function() {
console.log(buffer);
});
});

//發送資料
req.write(data);
req.end();