title: Do I need the promise in my MySQL statement?
body: <p>Below is a MySQL statement in my Node.js app. I used a promise in MySQL function to get API endpoint to work. Is this a typical pattern for Node.js and MySQL? </p>
  
  <pre><code>const express = require('express');
  const app = express();
  
  app.use(express.static('client'));
  const config = require('./config')
  
  var mysql = require('mysql');
  
  var con = mysql.createConnection({
      host: config.HOST,
      user: config.USER,
      password: config.PASSWORD,
      database: config.DATABASE
  });
  
  function GetConsumers(req, res) {
      return new Promise(function (resolve, reject) {
          con.connect(function (err) {
              if (err) throw err;
              con.query("SELECT * FROM " + config.DATABASE + ".Contracts", function (err, result, fields) {
                  if (err) throw err;
                  //console.log(result);
                  resolve(result);
              });
          });
      }).then(rows =&gt; res.send(rows));
  }
  
  app.get('/consumers', GetConsumers);
  
  module.exports = app;
  </code></pre>