title: Parse response body from request and return back to client
body: <p>I am new to node.js and JavaScript in general, but I'm trying to use node.js as a simple REST API. A client request comes to node.js, then node.js reaches out to a database to perform crud operations and returns the response back. However, I would like to be able to parse this response and format it in my own JSON before sending back to the client. Right now im using the request library and <code>.pipe()</code> to send back. Can I <code>.pipe()</code> into a variable that I could then parse or do I need to change my approach entirely?</p>
  
  <p>Here is what my code looks like at the current moment:</p>
  
  <pre><code>const request = require('request');
  
  var username = "admin";
  var password = "admin";
  var auth = "Basic " + new Buffer(username + ":" + password).toString("base64");
  
  exports.getPosts = (req, res, next) =&gt; {
      request({
          uri: 'http://localhost:8000/LATEST/search?q=caesar',
          headers: {"Accept": "application/json",
                  "Authorization": auth
          }   
      }).pipe(res);
  
  };
  </code></pre>
  
  <p>I am aware that <code>request</code> has been deprecated so maybe there is a better way to do this currently. I appreciate any help and feedback as I'm new to this.</p>