callback-hell
callback-hell copied to clipboard
Curring and closures
An example could be:
app.get('something', function (req, res) {
res.render('view1');
});
app.get('other', function (req, res) {
res.render('view1');
});
Refactor to:
function respondWithView (viewName) {
return function ( req, res ) {
res.render(viewName);
};
}
app.get('something', respondWithView('view1'));
app.get('other', respondWithView('view2'));