title: how to create onClick event in server side node JS simply?
body: <p>I just wanted this for test.</p>
  
  <p>For example, here is server code in node JS.</p>
  
  <p>As i mentioned below, i want to make onclick event properly and simply.</p>
  
  <p>Because it is just for test for client side. </p>
  
  <p>How to solve it? is that wrong way to use like this?? </p>
  
  <pre><code> http.createServer((request, response) =&gt; {
    return request
    .on('error', (err) =&gt; { 
      console.error(err);
    })
    .on('data', (data) =&gt; { 
        //data exists
  
      }).
    on('end',()=&gt;{
      response.statusCode = 200; 
      response.writeHead(200, {'Content-Type':'text/html'});
      response.write('&lt;html&gt;'); 
  
      response.write('&lt;h1&gt; List&lt;/h1&gt;'); 
      response.write('&lt;button onclick="sendToServer(data)"&gt;submit&lt;/button&gt;'); &lt;--this line
      //I want to make onclick event for above 
      //but it excutes even user didnt click the button
      response.write('&lt;/html&gt;'); 
     });
  }).listen(3030);
  
  
  function  sendToServer(data){
     request.post({
          headers: {
                    'Accept': 'application/json, text/plain, */*',
                    'Content-Type': "application/json"
                    },
              url:'https://...',
              body:JSON.stringify(data)
              }, function(e, r, body){
                console.log(body);
        });
   }
  </code></pre>