In PHP, I used to use output buffering to cache the output and save it as a html file. I was wondering if the same could be done in node.js. The following is my route file:
module.exports = {
 index: function(section,page,req,res){
  var l = res.locals,  
  db = l.db,
  Promise = l.Promise,
  Promise.props({
       my: db.db.query('CALL fetchdata()'),
       amba: db.db.query("CALL fetchanother()")
  }).then(function(obj){ 
       return res.render(section+'.html',obj)
    }).then(function(data){
       console.log(data);
       l.fs.writeFile('index.html', data)
    }).catch(function (error) {
       console.log(error);
    })
 }
};
return res.render(section+'.html',obj) isn't working. console.log(data) returns "undefined" in the console and the html file doesn't have anything but the word "undefined". I have also tried this:
    .then(function(obj){ 
       var cache
       res.render(section+'.html',obj,function(k,content){
           res.send(content)
           cache = content
       })
       return cache;
    }).then(function(data){
       console.log(data);
       l.fs.writeFile('index.html', data)
    })
It is still undefined. Is there a way to cache the view result as a html file?
 
     
    