var http = require("http");
var util = require("util");
var username = "user";
var password = 'pass';
http.request({
host: "127.0.0.1",
port:"8332",
path:"/path",
method: "POST",
headers: {
"Authorization": "Basic " + new Buffer( username + ":" + password ).toString('base64')
},
postData: {
mimeType: 'application/x-www-form-urlencoded',
params: [
{
jsonrpc: '1.0',
id: 'curltest',
method:'decoderawtransaction',
params:'010000000157065146a6b32b224b87d47c1b0283b1ae2fa5bd4f9af9ebc45928110f87fbae0000000070004830450'
}
]
}
},
function(res){
console.log(util.inspect(res, false, null));
var response = "";
res.on('data', function(chunk){
response += chunk;
console.log("res"+response);
});
res.on('end',function(){
response = JSON.parse(response);
console.log("res1"+response);
});
}).end();
我试图通过http请求获得基本auth和参数的响应,但我不响应,我怎么能通过这个方法得到结果, 如果有其他任何流程请帮助我..