Skip to content

Commit

Permalink
Merge pull request #1237 from vmattos/doc/streamErrorHandling
Browse files Browse the repository at this point in the history
Documenting error handling when using streams
  • Loading branch information
FredKSchott committed Nov 7, 2014
2 parents 987f467 + f8c7491 commit c456b71
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions README.md
Expand Up @@ -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
Expand Down

0 comments on commit c456b71

Please sign in to comment.