如何将带有数据(例如一些变量)的 POST 请求发送到 https 服务器并将结果显示给最终用户?
最佳答案
使用http.Client
模块。来自文档:
var http = require('http');
var google = http.createClient(80, 'www.google.com');
var request = google.request('GET', '/', {'host': 'www.google.com'});
request.end();
request.on('response', function (response) {
console.log('STATUS: ' + response.statusCode);
console.log('HEADERS: ' + JSON.stringify(response.headers));
response.setEncoding('utf8');
response.on('data', function (chunk) {
console.log('BODY: ' + chunk);
});
});
我很确定你可以用 POST
交换 GET
;)
关于javascript - 带有 node.js 中数据的 POST 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4460307/