Reputation: 1
var mysql = require('mysql');
var connection = mysql.createConnection({
host : 'localhost',
user : 'root',
port : '3306',
password : 'root',
database : 'test'
});
connection.connect(function(err){
if(!err) {
console.log("database is connected"+database);
} else {
console.log("database is not connected"+err.message);
}
});
Upvotes: 0
Views: 441
Reputation: 177
Change your connect function to look like this: (Replacing function with fat arrow function "=>")
connection.connect((err) => {
if (!err) {
console.log("database is connected"+database);
} else {
console.log("database is not connected"+err.message);
}
});
This below link explains why:
What is the difference between () => {} and function() {} in react-native javascript?
Upvotes: 0