I'm building a serverside parser of an API. Every get-request to my site needs to start with a request to that api, the request to the api is always the same, so I want to put it in it's own function.
How can I pass the response-variable from the api-function to the render-function?
var api = function (req, res, next) {
http.get({...}), function(response){}
next();
}
var render = function (req, res, next) {
app.res.render('master',response);
next();
}
app.get('/example/d', [api, render]);
You can assign it to req before calling next().
req.response = response;
And in your next...
var response = req.response;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With