0

I am using npm request package. In this I can t able to pipe after response is emitted. My code below

var fs = require('fs'),
  request = require('request');

var readStream = request({
  url: 'https://www.google.com'
});

// wait for 5 seconds, then pipe
setTimeout(function() {

  readStream.pipe(fs.createWriteStream('test.js'));

}, 5000);
Selvakumar
  • 527
  • 2
  • 13
  • [this](https://www.npmjs.com/package/request#streaming) example uses a callback instead of `setTimeout`. If the `setTimeout` function has no other purpose than to wait for the response, then you can use the method mentioned in the link. – Ritik Saxena Mar 19 '18 at 12:46

1 Answers1

0

Looks like there's an open issue on this: https://github.com/request/request/issues/887

Radu Luncasu
  • 975
  • 10
  • 17