I am trying to use streams to send data to a browser using Hapi, but I cannot figure out how to do this. In particular, I use the request module. According to the docs, the reply object accepts the stream, so I tried:
reply(request.get('https://google.com'));
Throws an error. The docs say that the stream object must be compatible with streams2 , so I tried:
reply(streams2(request.get('https://google.com')));
Now this does not cause a server-side error, but the request never loads in the browser (using chrome).
Then I tried this:
var stream = request.get('https://google.com'); stream.on('data', data => console.log(data)); reply(streams2(stream));
And the data was output to the console, so I know that the thread is not a problem, but rather Hapi. How can I get streams in Hapi for work?
Calbmer
source share