Closed markddrake closed 1 month ago
FYI: Cause by not importing 'mysql2/promise'.
However, I would not expect an internal error to bubble up...
Hi, @markddrake. Sorry, I missed this issue 🙋🏻♂️
It happens due to:
import mysql from 'mysql2'
// ...
this.pool = mysql.createPool(this.vendorProperties)
// ...
// ❌ this method expects for a callback (function), but gets an undefined
const connection = await this.pool.getConnection()
return connection
By using mysql
import, you need to use a callback to get the connection, for example:
let connection;
this.pool.getConnection((err, conn) => {
connection = conn;
});
return connection;
As an alternative, you also can use it like:
this.pool = mysql.createPool(this.vendorProperties).promise();
// Now, it will work
const connection = await this.pool.getConnection()
However, I would not expect an internal error to bubble up...
It's like trying to execute an undefined:
const cb = undefined;
// ❌ TypeError: cb is not a function
cb();
Given the following code
I get