Lets say I have multiple places where I call response.send(someData). Now I want to create a single global interceptor where I catch all .send meth
for those finding on google, based off the top answer:
app.use((req, res, next) => {
let oldSend = res.send
res.send = function(data) {
console.log(data) // do something with the data
res.send = oldSend // set function back to avoid the 'double-send'
return res.send(data) // just call as normal with data
}
next()
})