title: Save json object as a text file
body: <p>I am using an API for a Twitch.tv streaming bot called DeepBot.  </p>
  
  <p>Here is the link to it on github <a href="https://github.com/DeepBot-API/client-websocket" rel="nofollow">https://github.com/DeepBot-API/client-websocket</a></p>
  
  <p>My goal is to create a text document listing all the information pulled from the bot using the command <code>api|get_users|</code>.  The bot's response is always a json object. How can I take the json object from the bot and save it as a text file?  </p>
  
  <p>Edit: My code</p>
  
  <pre><code>var WebSocket = require('ws');
  var ws = new WebSocket('ws://Ip and Port/');
  ws.on('open', function () {
      console.log('sending API registration');
      ws.send('api|register|SECRET');
  });
  
      ws.on('close', function close() {
      console.log('disconnected');
  });
  ws.on('message', function (message) {
      console.log('Received: ' + message);
      });
  
  ws.on('open', function () {
      ws.send('api|get_users|');
  });  
  </code></pre>