比如这段代码:
async https_post(){
let url = 'https://www.4tuu.com/';
const request = require('request');
let post_data = {
action:'api_info',
}
let request_ops = {
url: url,
timeout:10000,
headers: {
},
};
request_ops = Object.assign({}, request_ops, {
form:post_data,
method: 'POST',
json: false,
agentOptions: {
},
});
request(request_ops, async function (err, res, aa){
console.log('err, res, aa', err, res, aa);
});
}
具体提示:
{ Error: socket hang up
at TLSSocket.onHangUp (_tls_wrap.js:1137:19)
at Object.onceWrapper (events.js:313:30)
at emitNone (events.js:111:20)
at TLSSocket.emit (events.js:208:7)
at endReadableNT (_stream_readable.js:1064:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
code: 'ECONNRESET',
path: null,
host: 'www.4tuu.com',
port: 443,
localAddress: undefined }
试了很多方法都不行。你们可以试试。
不过我使用一些在线post提交工具可以提交的。nodejs就不行,不知道为什么。