title: Returning Data From Express JS call (Using Fetch)
body: <p>I'm requesting data on my client from my database, but I'm unable to return the data when called. If I change the response method to <code>res.write()</code> my data is displayed on the page, but I need to return it into a variable instead as JSON. I've listed my server and client side code below. </p>
  
  <p>Server Side Code:</p>
  
  <pre><code>    app.get('/t',function(req,res){
  
        var connection = mysql.createConnection({host:'*****', user: '****', password: '****', database: '****'});
          connection.query('SELECT * FROM  apron', function (err, results, fields) {
          res.json(results); // results contains rows returned by server
          connection.end(); 
  });
  </code></pre>
  
  <p>Front-End Code (Fetch):</p>
  
  <pre><code>fetch('\t').then(function(result){
          return result.json();
      }).then(function(r){
          console.log(r);
      });
  </code></pre>