I have two Express controllers in Node.js, A and B, and A has a function that returns data. I want B to call that function, intercept the answer and return it after refactoring. Something like this:
A{
search(req,res){...}
}
B{
wrapper(req,res){
A.search(req,?).then((repsonse)=>{
<refactor response>;
res.send(refactoredData);
})
}
}
I can't figure out how to call A.search from B, and I don't want to change A, A.search has no next() in it, and if I call A.search(req,res) with the wrapper's parameters, I just redirected the call, right?