How can nodejshttp apis be used to simulate the submission of web form forms?

  node.js, question

Now an application needs to access TAM security authentication services under different domains, and needs to simulate the form form and submit it to WebSEAL. Thank you first. The following is the way I am trying to write http requests:

var http = require('http');
 var querystring = require('querystring');
 
 var post_options = {
 host: '192.168.1.22',
 port: '80',
 path: '/pkmslogin.form',
 method: 'post',
 auth: 'username:123456',
 'login-form-type':'pwd',
 headers: {
 'Content-Type': 'application/x-www-form-urlencoded'
 bracket
 };
 var post_data = querystring.stringify({
 username:'username',
 password:'123456',
 'login-form-type':'pwd'
 });
 
 
 // Set up the request
 var post_req = http.request(post_options, function(res) {
 res.setEncoding('utf8');
 console.log(JSON.stringify(res.headers));
 
 res.on('data', function (chunk) {
 
 Log ('response:' plus chunk');
 });
 });
 console.log(JSON.stringify(post_req.headers));
 
 
 // post the data
 //post_req.write(post_data);
 post_req.end();
Attention should also be paid to the following two points:
 
 // 1. Set the content length in the header
 headers: {
 'Content-length': post_data.length,
 'Content-Type': 'application/x-www-form-urlencoded'
 bracket
 
 var post_data = querystring.stringify({
 username:'username',
 password:'123456',
 'login-form-type':'pwd'
 });
 // 2. Parameters are written into the stream
 post_req.write(post_data);