I need to add a JavaScript file in HTML code and need to get the output of the added JavaScript file in the HTML page. Please help me, I'm stuck and this is my HTML code:
<!DOCTYPE html>
<html>
<body>
<script src="tst.js">
</script>
</body>
</html>
And this is my JavaScript code:
var mysql = require('mysql');
var connection = mysql.createConnection({
host : 'host',
user : 'user',
password : 'pass',
database : 'db',
insecureAuth : 'true'
});
connection.connect();
var json = '';
connection.query('SELECT * FROM SmartAG AS readings ORDER BY Timestamp DESC', function(err, rows, fields) {
if (err) throw err;
console.log('The solution is: ');
console.log(rows[0]); // results are coming here.
json = JSON.stringify(rows[0]);
console.log(json);
//output.innerHTML = JSON.stringify(json)
});
connection.end();
I am not getting any output on the HTML page with the added script file. Can you people help me?