【发布时间】:2018-12-26 17:20:41
【问题描述】:
request.get(fileLink)
.on('response', function(response) {
if (response.statusCode == 200 && response.headers['content-type'] == 'application/vnd.ms-excel') {
return true;
} else {
return false;
}
})
.pipe(fs.createWriteStream('data.xls'));
如果响应代码为 200 且内容类型为 application/vnd.ms-excel,我需要保存文件。如何组织代码?
【问题讨论】:
标签: javascript node.js conditional-statements