title: Write JSON data from front-end to back-end in nodejs
body: <p>I have ButtonClick.js and TakeData.js files. I defined my json data in TakeData.js as below</p>
  
  <pre><code>    var dataObj = {};
  var locationsObj = "locations";
  dataObj[locationsObj] = {};
  dataObj[locationsObj].source = [];
  dataObj[locationsObj].target = [];
  </code></pre>
  
  <p>When I click the button in ButtonClick.js and the code snippet as below</p>
  
  <pre><code>button()
  .container(g2)
  .text(text2)
  .count(1)
  .cb(function()
  {
      console.log(dataObj[locationsObj].source[0]);
      console.log(dataObj[locationsObj].source[1]);
      console.log(dataObj[locationsObj].target[0]);
      console.log(dataObj[locationsObj].target[1]);
  
      console.log("SaveFile");
  
  })();
  </code></pre>
  
  <p>I want to send json data into the nodejs file writing function as the following.</p>
  
  <pre><code>fs.writeFile('sample.txt', [need to insert my JSON], function(err) {
     if(err) return console.log(err);
      console.log('Hello JSON &gt; sample.txt');
  });
  </code></pre>
  
  <p>How can I do that? Is there another effective way?</p>