title: function and static reserved word in JS class
body: <p>I have learned NodeJS but I had some problems with <strong>_getProductsFromFile</strong> function in the <strong>Product</strong> class, I think the problem is <strong>static</strong> reserved word and the error i got was</p>
  <p><code>TypeError: this._getProductsFromFile is not a function at Function.fetchAll (/Users/huynhhuukhanh/HKhansh/BE/Learn-NodeJS/refactoring-MVC-pattern/models/product.js:57:10) at exports.getProduct (/Users/huynhhuukhanh/HKhansh/BE/Learn-NodeJS/refactoring-MVC-pattern/controllers/products.js:20:11) at Layer.handle [as handle_request] (/Users/huynhhuukhanh/HKhansh/BE/Learn-NodeJS/node_modules/express/lib/router/layer.js:95:5) at next (/Users/huynhhuukhanh/HKhansh/BE/Learn-NodeJS/node_modules/express/lib/router/route.js:137:13) at Route.dispatch (/Users/huynhhuukhanh/HKhansh/BE/Learn-NodeJS/node_modules/express/lib/router/route.js:112:3) at Layer.handle [as handle_request] (/Users/huynhhuukhanh/HKhansh/BE/Learn-NodeJS/node_modules/express/lib/router/layer.js:95:5) at /Users/huynhhuukhanh/HKhansh/BE/Learn-NodeJS/node_modules/express/lib/router/index.js:281:22 at Function.process_params (/Users/huynhhuukhanh/HKhansh/BE/Learn-NodeJS/node_modules/express/lib/router/index.js:335:12) at next (/Users/huynhhuukhanh/HKhansh/BE/Learn-NodeJS/node_modules/express/lib/router/index.js:275:10) at Function.handle (/Users/huynhhuukhanh/HKhansh/BE/Learn-NodeJS/node_modules/express/lib/router/index.js:174:3)</code></p>
  <p><strong>Code in models/product.js</strong></p>
  <pre><code>odule.exports = class Product {
    constructor(title) {
      this.title = title;
    }
  
    save() {
      this._getProductsFromFile((products) =&gt; {
        products.push(this);
        fs.writeFile(
          path.join(
            path.dirname(process.mainModule.filename),
            &quot;data&quot;,
            &quot;products.json&quot;
          ),
          JSON.stringify(products),
          (err) =&gt; {}
        );
      });
    }
  
    static fetchAll(cb) {
      this._getProductsFromFile(cb);
    }
  
    _getProductsFromFile(cb) {
      fs.readFile(
        path.join(
          path.dirname(process.mainModule.filename),
          &quot;data&quot;,
          &quot;products.json&quot;
        ),
        (err, fileContent) =&gt; {
          if (err) cb([]);
          else cb(JSON.parse(fileContent));
        }
      );
    }
  };
  </code></pre>
  <p>Code in controllers/products.js</p>
  <pre><code>const Product = require(&quot;../models/product&quot;);
  
  exports.postAddProduct = (req, res, next) =&gt; {
    const product = new Product(req.body.title);
    product.save();
    res.redirect(&quot;/&quot;);
  };
  
  exports.getProduct = (req, res, next) =&gt; {
    Product.fetchAll((products) =&gt; {
      res.render(&quot;shop&quot;, {
        prods: products,
        pageTitle: &quot;Shop&quot;,
        path: &quot;/&quot;,
        hasProducts: products.length &gt; 0,
        activeShop: true,
        productCSS: true,
      });
    });
  };
  
  </code></pre>
  <p>I need some help, please
  Thanks all.</p>