Last active
January 16, 2018 23:48
-
-
Save csakis/0ee7d9d93a5351b523ce3bd60f7481b7 to your computer and use it in GitHub Desktop.
onPreresponse interception of the response
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server.ext('onPreResponse', function (request, h) { | |
const response = request.response; | |
// if there's no Boom error, don't bother checking further down | |
if (!response.isBoom) { | |
return h.continue; | |
} | |
//let's handle login POST error | |
if (request.route.path == '/login' && request.route.method == 'post') { | |
//business logic comes here to extract the errors from response.details | |
return h.view('login', { | |
error: loginError | |
}); | |
} | |
return h.continue; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment