New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: how to stream array of urls into request? #71

Closed
Bondifrench opened this Issue Sep 20, 2014 · 1 comment

Comments

Projects
None yet
3 participants
@Bondifrench

Bondifrench commented Sep 20, 2014

I am trying to get my head around streams. I have an array of urls and want to call for each url, request, which returns a csv file, that i would like then to process.
I have tried to do it like this:

var es = require('event-stream'),
    request = require('request');

var items =['item1', 'item2',..,'itemN']

var reader = es.readArray(items);

reader
    .pipe(es.map(function (data, cb) {
        var csv = request(data);
        cb(null, csv);
    }))
    .pipe(process.stdout)

but it doesn't work, what would be the correct way to implement this? Thx

@kiddkai

This comment has been minimized.

kiddkai commented Nov 25, 2014

@Bondifrench

Request is a async function, try this way

request(url, function(err, res, body) {
  cb(null, body);
})

@right9ctrl right9ctrl closed this Sep 6, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment