// Pay. js
Var http = require ('http ');
Function epay (params)
{
Console. log ("come in ");
Var params = JSON. stringify ({
"Sign": "samples/DBwm6cyBe9Sr2rti1/SjWPcdXLoWIHWEJ9IFKPK + 3 ieKU/MkNqeh1opH/4MEM59W314jQL3/sPS + samples/Bv7ck = "});
Var options = {
Host: '2017. 0.0.1 ',
Port: 80,
Path: '/index /',
Method: 'post ',
Headers :{
'Content-type': 'application/x-www-form-urlencoded ',
'Content-length': params. Length
}};
// Send with http
Var req = http. request (options, function (res ){
Console. log ('status: '+ res. statusCode );
Console. log ('headers: '+ JSON. stringify (res. HEADERS ));
// Set the character encoding
Res. setEncoding ('utf8 ');
// Return data stream
Var _ data = "";
// Data
Res. on ('data', function (chunk ){
_ Data + = chunk;
Console. log ('body: '+ chunk );
});
// End callback
Res. on ('end', function (){
Console. log ("REBOAK:", _ data)
});
// Error callback // This is required. Otherwise there will be a lot of trouble
Req. on ('error', function (e ){
Console. log ('problem with request: '+ e. message );
});
});
Req. write (params + "\ n ");
Req. end ();
}
Exports. epay = epay;
// Index. js Main Entry
Var epay = require ('./EPA ');
Console. log ('stert epaying ');
Epay. epay ("");
Run cmd to enter the node command.
> Node index. js