I have a hapi.js route where I want to defer the response. I\'ve tried storing the reply
function and calling it later, or wrapping it in a promise, but hapi alway
Since the version 8, Hapi supports Promised responses, so you can do :
var respond = function(message) {
return new Bluebird.Promise(function(resolve, reject) {
setTimeout(() => {
resolve(message);
}, 2000);
});
};
server.route({
method: 'GET',
path: '/',
handler: function (request, reply) {
reply(respond("Hello buddy"));
}
});