Open alejandrofdez-us opened 6 years ago
You can pipe request to parser and use event data
JSONStream.parse([true])
.pipe(
request(
{
method: 'POST',
url: this.url.href + '/_bulk_docs',
headers: this.headers
},
function (err, res, body) {
if (err) {
console.log('RESPONSE ERROR:', err)
return
}
if (res && res.statusCode !== 201) {
console.log(res.statusMessage, res.body)
}
})
)
.on('error', err => {
console.error('INPUT ERROR:', err)
})
.on('data', doc => {
console.log(doc.toString())
// or write to other stream e.g. JSONStream.stringify()
})
.on('end', () => {
// Event on end
})
Any sample of this? Thanks in advance!