Node request pipe

var request = require('request');
var fs = require('fs');
request('https://www.npmjs.com/package/request', function (error, response, body) {
  if (!error && response.statusCode == 200) {
    console.log('ok');
  }
}).pipe(fs.createWriteStream('request.html'));

这段代码会生成一个request.html文件

你可能感兴趣的:(Node request pipe)