I want to slightly change default expressjs behaviour of res.json(obj)
method. I am trying to override it in my own middleware, the thing is I need to call its original inside.
But now it just calls itself causing a stack overflow.
app.use(function(req, res, next) {
res.json = function(obj) {
function delete_null_properties(obj) {
// ...
}
delete_null_properties(obj);
res.json(obj);
};
next();
});