diff --git a/README.md b/README.md index 7297108a2..94b633506 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,17 @@ request .pipe(request.put('http://mysite.com/img.png')) ``` +To easily handle errors when streaming requests, listen to the `error` event before piping: + +```javascript +request + .get('http://mysite.com/doodle.png') + .on('error', function(err) { + console.log(err) + }) + .pipe(fs.createWriteStream('doodle.png')) +``` + Now let’s get fancy. ```javascript