HTTP请求输出的数据正在控制台中。我需要分配一个变量
const options = {
hostname: 'abcdef',
port: 443,
path: '/xyz',
method: 'GET',
rejectUnauthorized: false,
requestCert: true,
agent: false
};
https.request(options, (res) => {
res.on('data', (d) => {
process.stdout.write(d);// this will print to the console
});
}).on('error', (e) => {
console.error(e);
}).end();
我是node.js的新手,请帮助我解决这个问题。
答案 0 :(得分:1)
因为没有为sql = "select num_store, sum(gross_sales) as gross_sales from dtm.sales where day = " + input_date.strftime('%Y-%m-%d') + ...
设置encoding
,所以其数据将显示为response
。您需要Buffer
从响应数据中获取字符串值