I am creating REST api with hapi and mongojs. I need to output large number of JSONs as API response. I am using following code. But getting error “Error: Stream must have a streams2 readable interface”.
handler: function(request, reply) {
reply(db.collection.find().pipe(JSONStream.stringify()));}
How do I convert mongojs object stream to readable stream?
I tried following code as well
var outputStream = db.collection.find().pipe(JSONStream.stringify());
reply(outputStream.pipe(new Readable().wrap(outputStream)));
but it doesn't show any data in output.