Im looking for the parllel method in hapi
// Express + Request exmaple
function(req, res){
  request('http://example.com/image.png').pipe(res);
}
How to pipe a response in hapi ?
server.route({
method:  "*",
path:    "/api/results/{date}",
handler: (request, reply) => {
    //????reply(?);
}
});  
From another question/answer:
function (request, reply) {
    Request('http://example.com/image.png')
    .on('response', function (response) {
        reply(response);
     });
}
https://stackoverflow.com/a/31222563/2573244
If you only need to forward an upstream response, you can just use a proxy handler via the h2o2 plugin:
server.route({
    method: 'GET',
    path: '/upstream/file',
    handler: {
        proxy: {
            uri: 'http://example.com/image.png'
        }
    }
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With