A
A
Aryeh Leonid R.2021-04-08 17:00:24
Express.js
Aryeh Leonid R., 2021-04-08 17:00:24

How to add a res.send() handler to Express.js?

I have a server written in Express.js
How can I add a handler to be called before each call to res.send()?
Something I'm confused...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
StiflerProger, 2021-04-08
@aryeh

Through use, rewrite the response function

app.use(function (req, res) {
    var send = res.send;
    res.send = function (body) {
        // тут что надо делай
        send.call(this, body);
    };
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question