var response_text=""; const mysql = require('mysql'); const connection = mysql.createConnection({ host: 'localhost', user: 'root', password: 'root', database: 'nodeapi' }); connection.connect((err) => { if (err) throw err; console.log('Connected to MySQL Server!'); }); connection.query("SHOW tables", function (err, rows) { console.log(rows); response_text += rows.length + " table" + (rows.length > 1 ? "s" : "") + " found"; console.log(response_text); });