Below is the simple route I have in place:
router.get('/:date', async (req, res) => {
let tracks = []
let query = 'SELECT * from `tracks` where `playlistDate` = \''+req.params.date+'\''
let result = await pool.query(query)
console.log(result)
})
I understand that this code alone won't function correctly. What steps should I take to ensure that I can use the await keyword with the query function as shown here?
The following code snippet shows the database connection pool, but with altered credentials.
var pool = mysql.createPool({
poolLimit : 10,
host : 'HOST',
user : 'USER',
password : 'PASS',
database : 'DB'
});