title: How to pass data from Node.js to html
body: <p>I have a simple program and some data strings that I want to pass to HTML page that hosted locally, but I'm getting error: ReferenceError: document is not defined</p>
  <p>There's my .js file <strong>index.js:</strong></p>
  <pre><code>let some_string = &quot;some data&quot;;
  
  document.getElementById(&quot;dataButton&quot;).onclick = function(){
      var paragraph = document.createElement(&quot;p&quot;);
      var text = document.createTextNode(some_string); 
      paragraph.appendChild(text);
      var element = document.getElementsByTagName(&quot;body&quot;)[0];
      element.appendChild(paragraph);
  }
  </code></pre>
  <p>And there's my HTML <strong>test.html:</strong></p>
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  
  &lt;head&gt;
      &lt;title&gt;New title&lt;/title&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
      &lt;h1&gt;Data page&lt;/h1&gt;
  
      &lt;button id=&quot;dataButton&quot;&gt;Add data&lt;/button&gt;
      &lt;script src=&quot;index.js&quot;&gt;&lt;/script&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  <p>Many thanks if someone come up with idea what am I doing wrong!</p>