title: Cannot read property 'toString' of undefined node.js filesystem
body: <p>I have this script here, upon loading the page, it should first load a header html boilerplate, some dynamic paragraphs, and end the request with a footer html boiler plate. Both Boilerplates come from external files.</p>
  
  <p>After testing, I am receiving: </p>
  
  <p><strong>TypeError: Cannot read property 'toString' of undefined
      at ReadFileContext.callback (/user_code/index.js:20:23)
      at FSReqWrap.readFileAfterOpen [as oncomplete] (fs.js:367:13)</strong></p>
  
  <p>My understanding was that I needed <strong>.toString()</strong> to ensure that what was loaded from the external files were buffered as strings.</p>
  
  <pre><code>exports.request = functions.https.onRequest((req, res) =&gt; {
  
          fs.readFile('/public/templates/header-template.html', function(_err, data) {
              res.write(data.toString());
              console.log('Header Loaded');
          });
  
          res.writeHead(200, {'Content-Type': 'text/html'});
          var q = url.parse(req.url, true).query;
          var txt = '&lt;p&gt;Thanks &lt;b&gt;' + q.firstname + ' ' + q.lastname + '&lt;/b&gt;. An email has been sent to &lt;b&gt;' + q.email + '&lt;/b&gt; with details about your request.';
          res.write(txt);
  
          fs.readFile('/public/templates/footer-template.html', function(_err, data) {
              res.end(data.toString());
              console.log('Footer Loaded');
          });
  
      });
  </code></pre>
  
  <p>Any idea what I am doing wrong?</p>