I am using {{#each rows}} loop in a view, but the objects array that it is iterating through is not rendering. The object array is displayed if I use res.send(rows), so the database is returning results. When running this server on the cloud9 platform, the view renders with the table filled with the object attributes, but when I try running this server on my Amazon Web Server, the view renders but the #each loop does not render, in fact, when looking at the page source it is as though rows was not even received. But again, if I do a res.send(rows) the rows object array is displayed. I would really appreciate any help at all.
//Here is the code in my server:
var express = require('express');
var mysql = require('./dbContentPool.js');
var bodyParser = require('body-parser');
var app = express();
var handlebars = require('express-handlebars').create({defaultLayout:'main'});
app.use(express.static('public'));
app.engine('handlebars', handlebars.engine);
app.set('view engine', 'handlebars');
app.set('port', 3000);
app.use(express.static(__dirname + '/public'));
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.get('/Donors/business', function(req, res, next){
mysql.pool.query('SELECT * FROM ' + 'business', function(err, rows, fields){
if(err){
next(err);
return;
}
res.render('Donors/business/index', rows);
});
});
//here is the code in my view called 'Donors/business/index':
<h1>Donors</h1>
<div class="col-md-8">
<table class="table table-striped table-hover">
<thead>
<tr>
<th>Name
<th>Address
<th>City
<th>State
<th>Zip
<th>Specific Location</th>
</tr>
</thead>
<tbody>
{{#each rows}}
<tr>
<td>{{this.name}}
<td>{{this.street_address}}
<td>{{this.city}}
<td>{{this.state}}
<td>{{this.zip}}
<td>{{this.specific_location}}
</tr>
{{/each}}
</tbody>
</table>
</div>
<div class="col-md-4">
<form role="form" action="/Donors/business" method="POST">
<fieldset>
<legend>See Available Food From a Specific Donor:</legend>
<div class="form-group">
<label for="Specific_donor">Pick a Specific Donor:</label>
<select class="form-control" name="business_id" id="business_id">
<option>--Select Donor--</option>
{{#each businesses}}
<option value={{this.id}}>{{this.name}}</option>
{{/each}}
</select>
<input type="submit" id="entrySubmitABusiness" class="btn btn-primary">
</fieldset>
</form>
</div>