How to pass stream for response in hapi.js

I am looking for the parllel method in hapi

// Express + Request exmaple function(req, res){ request('http://example.com/image.png').pipe(res); } 

How to pass an answer to hapi?

 server.route({ method: "*", path: "/api/results/{date}", handler: (request, reply) => { //????reply(?); } }); 
+7
javascript stream hapijs
source share
2 answers

From another question / answer:

 function (request, reply) { Request('http://example.com/image.png') .on('response', function (response) { reply(response); }); } 

fooobar.com/questions/827786 / ...

+6
source share

If you only need to redirect the upstream response, you can simply use the proxy handler through the h2o2 plugin:

 server.route({ method: 'GET', path: '/upstream/file', handler: { proxy: { uri: 'http://example.com/image.png' } } }); 
+3
source share

All Articles