New to the MEAN stack, trying to make an API response I have properly available to the res.render jade template below.
exports.jap = function(req, res){
var client = new BasicAuth();
client.authenticate(function(err, response, body, cookie) {
var client = new Api('sample.com', cookie);
client.getProducts(function(err, response, body) {
console.log(JSON.stringify(body['result']));
var result = body['result'];
console.log(result);
});
});
res.render('lang', {
title: "灾情 (Mandarin)",
reqFor: "申请人",
product: "产品",
problem: "问题",
results: result // I would like my result var from above accessable here
});
};
Right now I'm getting result is not defined