Why doesn't request.on() work in Node.js
问题 I'm trying to get some data from a third party service using the node request module and return this data as string from a function. My perception was that request() returns a readable stream since you can do request(...).pipe(writeableStream) which - I thought - implies that I can do function getData(){ var string; request('someurl') .on('data', function(data){ string += data; }) .on('end', function(){ return string; }); } but this does not really work. I think I have some wrong perception