title: How to use Node.js to read data from a json file and display the read data into html?
body: <p>I am a complete newbie and just did something like this:</p>
  
  <pre><code>    var fs = require('fs');
      var file = __dirname + '/data.json';
      var http = require ('http');
      var server = http.createServer(function (req, res){
      res.writeHead(200);
  
      fs.readFile(file, 'utf8', function (err, data) {
              if (err) {
              console.log('Error: ' + err);
              return;
              }
  
      data = JSON.parse(data);
  
      res.end(data);
      });
  
  
      });
          server.listen(8000);
  </code></pre>
  
  <p>When I am doing:</p>
  
  <pre><code>    data = JSON.parse(data);
      console.dir(data);
  </code></pre>
  
  <p>Instead of </p>
  
  <pre><code>    data = JSON.parse(data);
      res.end(data);
  </code></pre>
  
  <p>It is able to display the data I have in .json on the console. However when I am trying to create a server and post the data using res.end, it doesn't really work. </p>
  
  <p>Could someone offer some insights? Is it because the "data" I have here is only an object? How should I process the data I get from .json in order to use for my html? </p>