title: Populating a select menu with mysql values in node.js, express and jade
body: <p>I am new to node.js, i want to know how to populate a select menu on page load with mysql values. I am using nodejs, expressjs and jade/pug. I am unable to find any solution in google.</p>
  
  <p>Jade file:-</p>
  
  <pre><code>block sale
   form(action = "/get_sale", method = "GET")
    select(id="cbosale", name="cbosale", class="custom-select custom-select-sm")
     each sale in ["24", "34"]
      option(value="#{sale}") #{sale}
  </code></pre>
  
  <p>App.js file:-</p>
  
  <pre><code>app.get('/get_sale', function(req, res){
   db.connect(function(err){
    db.query("SELECT DISTINCT(SaleNo), Season FROM tcatalogue",function(err, result, fields){
    Object.keys(result).forEach(function(key){
      var row = result[key];
      console.log(row.SaleNo)
    })
  })
  })
  })
  </code></pre>
  
  <p>Instead of the static values in the jade file, values should be fetched from the app.js file.</p>