Reputation: 1691
can't get data from mysql db in nodejs in routes '/users'
app.get('/users', function(req,res){
connection.query("select * from users",function(err,rows){
if(!err) {
res.json(rows);
}else{
console.log(err);
res.send('err here !!' + err);
}
connection.end();
});
});
take much time and then response with
ERR_EMPTY_RESPONSE
db connection
var connection = mysql.createConnection({
host : 'localhost',
port : port,
database : 'test',
user : 'root',
password : 'root'
});
can some one help me to track this issue , Thanks in advance.
Upvotes: 0
Views: 284
Reputation: 1691
This issue has been resolved: I defined the MySql port as 8080
by mistake.
I corrected the port to 3306
.
Upvotes: 1