title: Why I don't get the data when going on the route?
body: <p>When I go to route <code>'/gallery'</code>, I want to receive data from the file "posts.json".
  I get the data from the file using the <code>fs</code> module and using the <code>read()</code> method for read data from a file "posts.json".  </p>
  
  <p>As a result, I get the error: 'ReferenceError: fs is not defined'</p>
  
  <p><strong>How to implement show data from the file "posts.json" when navigating through the route <code>'/gallery'</code> using the <code>fs</code> module?</strong></p>
  
  <p><strong>app.js:</strong></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>const express = require('express');
  const  Database =  require('./db');
  
  const app = express();
  const port = 3000;
  const  db = new Database();
  
  app.use(express.json());
  
  app.get('/gallery', (req, res) =&gt; {
      const items = db.read();
      res.send(items);
  });
  
  app.listen(port, () =&gt; {
      console.log(`Example app listening on port ${port}!`);
  });</code></pre>
  </div>
  </div>
  </p>
  
  <p><strong>db.js:</strong></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>class Database {
  
      constructor(){
          this.fs = require('fs');
          this.pictures = [];
      }
  
      read() {
          fs.readFile('./posts.json', (err, data)=&gt; {
              if(err) {
                  throw err;
              }else {
                 return this.pictures = data;
              }
          });
      }
  }
  
  module.exports = Database;</code></pre>
  </div>
  </div>
  </p>