I have an array of parameters, which I then transform into an array of urls. I would like to then stream this array of urls to request.
var parameters = [1,2,.., n]
var urls = [];
parameters.forEach(function(item) {
urls.push('http://www.example.com/page'+item)
})
Using the module event-stream I can transform this array into a stream like this:
var es = require('event-stream');
var reader = es.readArray(urls);
I can then do:
reader.pipe(process.stdout)
I know how to use request
so I can pipe its result like this:
request(url).pipe(csvToJson).pipe(fs.createWriteStream('destinationFile'))
But how can I stream the array of urls into request, if that's possible?