I’ve taken a look at this article and the suggestion solution stopped working for me after a few hours.
I’m attempting to use the MySQL template for creating a user for a custom database.
As suggested, I changed the code to follow the solution.
function create(user, callback) {
const mysql = require('mysql');
const bcrypt = require('bcrypt');
const connection = mysql.createConnection({
host: 'xxx',
user: 'xxx',
password: 'xxx',
database: 'xxx'
});
connection.connect();
const query = 'INSERT INTO manager SET ?';
const insert = {
password: 'hello',
email: user.email
};
connection.query(query, insert, function(err, results) {
if (err) return callback(err);
if (results.length === 0) return callback();
callback(null);
});
}
I’m receiving a [SandboxUnhandledError] mysql is not a function
error when using the prompt to test the creation of the user.