What is the right way to redirect from within a keystone.js view?
I have this use case:
//req, res are the express request and response objects defined earlier
view.on('init', function(next){
if (req.params['should-be-else-where']='true'{
// do some logging stuff
// redirect to somewhere else
}
});
as I understand the next param in the view.on()
function is a callback for the async.js framework, and does not relate to the (req,res,next) middleware.
Should I call res.redirect('/somewhere-else)
and then call next()
, then call next()
with a non-null error parameter, or should redirection be performed somewhere completely different?
Additional info: I'd like to stop processing because there is no reason to do the performance heavy database processing that following later in the queue