I am working on a project where I need to modify the behavior of the res.render
method in order to consistently include an additional option, regardless of any other options present. However, when attempting to implement this modification, I encounter the error described above. Here is the current implementation of my middleware code:
app.use((_, res, next) => {
const oldRender = res.render;
res.render = (view, options, callback) => {
if (typeof options === "function") {
callback = options;
options = {};
}
options.stops = stops?.data || {};
oldRender.call(this, view, options, callback);
};
next();
});