Something weird is happening here. This is my code :
app.get('/', function (req, res) {
connection.query('SELECT message FROM messages', function(err, docs, fields) {
if (err) {
throw err;
}
console.log(fields);
if(docs[0].message!='') {
res.render('page', {messages: docs});
}
else {
res.render('page');
}
});
});
if there are any rows in the "messages" table, it's working fine, but if its empty, its returning this error at the "if (err) {" line :
Error: Must have start <= end
at Buffer.toString (buffer.js:416:26)
Any idea what is happening here?
connection
? Are you using a particular package?