Hacker News new | ask | show | jobs
Node.js modules you should know about: request (catonmat.net)
59 points by holi2007 5309 days ago
4 comments

This is one of the modules everyone starts to build themselves, then realizes there's a much better version already built.
Unfortunately I've had the opposite experience: trying to use request then finding that I have to build my own. Mainly because it has no good pattern for both streaming and catching errors in a predictable fashion, the streaming isn't true streaming in most cases (try a 5GB file), and with binary files, it's tricky to nail the right encoding.
Just to clarify: the sorts of things I'm using an HTTP Get-type library for are atypical and request is fantastic for 95% percentage of uses. And the library I wrote ( https://github.com/developmentseed/node-get ) isn't recommended for use if you aren't me. Though it does a decent job of staying out of your way.
I agree about the encoding problems, particularly when using buffers. No combination seemed to allow me to download a binary file and then upload. But this was my first few hours with Node so I'm open to correction. In the end I was able to use .pipe which correctly managed the encoding
Request is really quite nice. It's the simple high-level counterpart to node's low-level HTTP client. Very useful "sweet spot" in the abstraction levels.
I like how SubStack put it - request is the swiss army knife of HTTP streaming.
Nice nodejs version of Python's Request[1] and/or Ruby's Farday[2]

[1] http://docs.python-requests.org/en/latest/index.html

[2] https://github.com/technoweenie/faraday

This is great, can't wait to start replacing old code! No more complicated multi-line monster requests+callbacks.