fetchival
fetchival copied to clipboard
get body on 400 error
How to get json
body from a code 400 server response?
I can see only the body: PassThrough { ... }
stream. Aren't chunks collected and json parsed?
Right now I'm doing concat myself.
function concatStream(stream) {
return new Promise((resolve, reject) => {
let result = ''
stream.on('data', (chunk) => {
result += chunk.toString()
})
stream.on('end', () => {
resolve(JSON.parse(result))
})
stream.on('error', (err) => reject(err))
})
}