0

I have found only the code to display a HTML file :

app.get('/',function(req,res){

 res.sendFile('index.html');

});

While I want just to get the HTML in a variable (to sent it later only if needed). So I look for something like this (with express.js) :

app.get('/',function(req,res){

 var example = res.readFile('index.html');

});
Ellno
  • 11
  • 2
  • I'm trying to find a duplicate for this, but every question I find assumes you've already figured out that you need to use the `fs` module and not the response object. – Quentin Dec 06 '17 at 17:17
  • ok I have found myself, as I knew that I had to use fs (thanks) : https://stackoverflow.com/questions/18494226/storing-nodejs-fs-readfiles-result-in-a-variable-and-pass-to-global-variable – Ellno Dec 06 '17 at 18:20

0 Answers0