Skip to content

Commit

Permalink
Add new PassThrough() to stream example
Browse files Browse the repository at this point in the history
Fixes #1742
  • Loading branch information
szmarczak committed Jul 13, 2021
1 parent 163ea13 commit 59b9aed
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion documentation/3-streams.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,15 @@ await pipeline(
// For POST, PUT, PATCH, and DELETE methods, `got.stream` returns a `stream.Writable`.
await pipeline(
fs.createReadStream('index.html'),
got.stream.post('https://sindresorhus.com')
got.stream.post('https://sindresorhus.com'),
new stream.PassThrough()
);
```

Please note that `new stream.PassThrough()` is required in order to catch read errors.\
If it was missing then `pipeline` wouldn't catch any read errors because there would be no stream to pipe to.\
In other words, it would only check errors when writing.

### `stream.options`

**Type: [`Options`](2-options.md)**
Expand Down

0 comments on commit 59b9aed

Please sign in to comment.