Open
Description
Describe the bug
- Node.js version: 15.11.0
- got version: 11.8.2
- OS & version: Windows
Actual behavior
response.rawBody <Buffer ...>
On error, got.stream response is not pipable. The response body is under response.rawBody
which is supposed to be "only accessible when using Promise API" (https://github.com/sindresorhus/got/blob/main/documentation/3-streams.md#rawbody). I would assume there's no data
event as the response body has already been consumed?
Expected behavior
on data <Buffer ...>
Code to reproduce
const got = require('got')
const url = 'https://run.mocky.io/v3/99fc1661-4a34-4334-a123-ae9c02b33db4'
got.stream(url)
.on('error', error => {
const { response } = error
console.log('response.rawBody', response.rawBody)
})
.on('data', chunk => {
console.log('on data', chunk)
})
Checklist
- I have read the documentation.
- I have tried my code with the latest version of Node.js and Got.