Is this the right way to use async/await with the JavaScript MySQL client? I had to use the promise-mysql package because it wraps the function calls with Bluebird promises, so that I'm able to use async/await.
const express = require('express');
const mysql = require('promise-mysql');
let app = express();
let pool = mysql.createPool({
host: '',
user: '',
password: '',
database: ''
});
app.get('/', async (req, res) => {
try {
let conn = await pool.getConnection();
let results = await conn.query('SELECT 1 + 1');
res.send(results[0]);
} catch (err) {
return res.send(err);
}
});
app.listen(3000, () => {
console.log('server is listening on port 3000');
});