diff --git a/lib/apiswagger.js b/lib/apiswagger.js index 42a147e..d8cd8dd 100644 --- a/lib/apiswagger.js +++ b/lib/apiswagger.js @@ -481,20 +481,21 @@ module.exports = (app, client) => { parser(), pick({ filter: 'hits.hits' }), streamArray(), - data => { - block_count++ - instancescomment.push({ - instance: data.value._source.instance, comment: data.value._source.blocks.find(block => block.domain === clean(req.params.instance)).comment - }) - } + data => data.value._source ]) - result.pipe(pipeline) + pipeline.on('data', data => { + block_count++ + instancescomment.push({ + instance: data.instance, comment: data.blocks.find(block => block.domain === clean(req.params.instance)).comment + }) + }) pipeline.on('end', () => { res.json({ block_count, instances: instancescomment }) }) + result.pipe(pipeline) } else { res.status(404).end() }